Replication Stage #ZN8 Help

I’m trying to propagate the commands, locally it works perfectly using this code:

func (r *RedisReplicaInfo) Propagate(rawCommand string) {
	fmt.Println("Propagating to replica: ", r.port)
	fmt.Println("Command: ", rawCommand)

	d, err := net.Dial("tcp", "localhost:"+r.port)
	if err != nil {
		fmt.Printf("Failed to connect to replica during the propagate to %s\n", r.port)


But for some reason, when I run codecrafters test or making a git push, it fails with:

remote: [replication-11] Reading RDB file...
remote: [replication-11] replica: Received bytes: "$88\r\nREDIS0011\xfa\tredis-ver\x057.2.0\xfa\nredis-bits\xc0@\xfa\x05ctime\xc2m\b\xbce\xfa\bused-mem°\xc4\x10\x00\xfa\baof-base\xc0\x00\xff\xf0n;\xfe\xc0\xffZ\xa2"
remote: [replication-11] Received RDB file
remote: [replication-11] client: $ redis-cli SET foo 123
remote: [replication-11] client: Sent bytes: "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\n123\r\n"
remote: [your_program] Received:  *3
remote: [your_program] $3
remote: [your_program] SET
remote: [your_program] $3
remote: [your_program] foo
remote: [your_program] $3
remote: [your_program] 123
remote: [your_program] 
remote: [your_program] Command:  [set foo 123 ]
remote: [your_program] Propagating to replica:  6380
remote: [your_program] Command:  *3
remote: [your_program] $3
remote: [your_program] SET
remote: [your_program] $3
remote: [your_program] foo
remote: [your_program] $3
remote: [your_program] 123
remote: [your_program] 
remote: [your_program] Failed to connect to replica during the propagate to 6380
remote: [your_program] dial tcp [::1]:6380: connect: connection refused
remote: [replication-11] Received: "" (no content received)
remote: [replication-11]            ^ error
remote: [replication-11] Error: Expected start of a new RESP value (either +, -, :, $ or *)
remote: [replication-11] Test failed
remote: [replication-11] Terminating program
remote: [replication-11] Program terminated successfully

I tried with localhost, [::1],, but i only received the port during the handshake. Am I missing something?


Hey @raphaelkieling!

Propagated commands are sent on the same connection used for the handshake, not using a separate connection. The replicas we spawn intentionally don’t listen on listening-port. This can happen in real life - you can have replicas that aren’t “reachable” from the master, but they can still replicate because they can reach the master.

I’ve noticed a few others make the same mistake too, so we’ll make the docs more clear here. Will keep this open until we’ve updated docs!

1 Like

This has now been clarified in the instructions!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.

Note: I’ve updated the title of this post to include the stage ID (#ZN8). You can learn about the stages rename here: Upcoming change: Stages overhaul.