# Unable to spawn 'Slave' process. Stage 6 (sending handshake 2/3) of Redis Replication extension

**URL:** <https://forum.codecrafters.io/t/unable-to-spawn-slave-process-stage-6-sending-handshake-2-3-of-redis-replication-extension/1456>\
**Category:** Challenges\
**Tags:** challenge:redis\
**Created:** [August 21, 2024, 11:29am UTC](https://forum.codecrafters.io/t/unable-to-spawn-slave-process-stage-6-sending-handshake-2-3-of-redis-replication-extension/1456 "2024-08-21T11:29:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![soodankit91](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/soodankit91/32/1343_2.png) [@soodankit91](https://forum.codecrafters.io/u/soodankit91)\
**Post date:** [August 21, 2024, 11:29am UTC](https://forum.codecrafters.io/t/unable-to-spawn-slave-process-stage-6-sending-handshake-2-3-of-redis-replication-extension/1456/1 "2024-08-21T11:29:27Z")

</div>

I’m stuck on Stage #EH4

Unable to spawn a slave process on the specified port on localhost

I’ve tried … flushing streams and ensuring all connections and streams are closed.

Here are my logs:

```auto
[tester::#HC6] Running tests for Stage #HC6 (Replication - The INFO command on a replica)
[tester::#HC6] Master is running on port 6379
[tester::#HC6] $ ./spawn_redis_server.sh --port 6380 --replicaof "localhost 6379"
[your_program] Logs from your program will appear here!
[your_program] ping response = 43
[your_program] repl conf response = 80
[your_program] repl conf response = 79
[tester::#HC6] dial tcp 127.0.0.1:6380: connect: connection refused
[tester::#HC6] Test failed
[tester::#HC6] Terminating program

```

And here’s a snippet of my code:

```scala
private def slaveConnectMaster(host: String, port: Int): Unit = {
    val masterSocket = new Socket(host, port)
    val outputStream: OutputStream = masterSocket.getOutputStream
    val writer = new PrintWriter(outputStream, true)
    val inputStream = masterSocket.getInputStream
    val reader = new InputStreamReader(inputStream)

    writer.print("*1\r\n$4\r\nPING\r\n")
    writer.flush()
    val pingResponse = reader.read()
    println(s"ping response = ${pingResponse}")
    writer.print("*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n")
    writer.flush()
    val replConfResponse = reader.read()
    println(s"repl conf response = ${replConfResponse}")
    writer.print("*3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n")
    writer.flush()
    val replConfResponse2 = reader.read()
    println(s"repl conf response = ${replConfResponse2}")

    writer.close()
    reader.close()
    outputStream.close()
    inputStream.close()
    masterSocket.close()
  }

```

---

<div class="post-metadata">

**Author:** ![soodankit91](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/soodankit91/32/1343_2.png) [@soodankit91](https://forum.codecrafters.io/u/soodankit91)\
**Post date:** [August 22, 2024, 2:04pm UTC](https://forum.codecrafters.io/t/unable-to-spawn-slave-process-stage-6-sending-handshake-2-3-of-redis-replication-extension/1456/2 "2024-08-22T14:04:09Z")

</div>

There was a mistake in my code. This issue is resolved now.

---

<div class="post-metadata">

**Author:** ![rohitpaulk](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rohitpaulk/32/6_2.png) [@rohitpaulk](https://forum.codecrafters.io/u/rohitpaulk)\
**Post date:** [August 23, 2024, 10:30am UTC](https://forum.codecrafters.io/t/unable-to-spawn-slave-process-stage-6-sending-handshake-2-3-of-redis-replication-extension/1456/3 "2024-08-23T10:30:48Z")

</div>

@soodankit91 thanks for letting us know! What was the error btw? Would be helpful for others who might stumble upon this in the future.

---

<div class="post-metadata">

**Author:** ![soodankit91](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/soodankit91/32/1343_2.png) [@soodankit91](https://forum.codecrafters.io/u/soodankit91)\
**Post date:** [August 23, 2024, 5:46pm UTC](https://forum.codecrafters.io/t/unable-to-spawn-slave-process-stage-6-sending-handshake-2-3-of-redis-replication-extension/1456/4 "2024-08-23T17:46:21Z")

</div>

@rohitpaulk  
I was trying to connect to the master process before spinning my worker process 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [August 28, 2024, 5:47pm UTC](https://forum.codecrafters.io/t/unable-to-spawn-slave-process-stage-6-sending-handshake-2-3-of-redis-replication-extension/1456/5 "2024-08-28T17:47:00Z")

</div>

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