This is specifically for the Redis Challenge. For debugging test failures for common challenges, refer to our guide.
The easiest way to debug problems with your redis implementation is to compare it to the official implementation. To do this, we’ll need a few tools handy.
Since redis-cli & redis-server communicate with each over using TCP, we’ll need a tool to inspect TCP messages. Install Wireshark.
Run Wireshark and use
tcp.port == 6379 or
tcp.port == 6380 as a display filter. We’ll use this in step 4 to view captured packets.
You’ll find instructions for this in your repository’s README (like here). Your server will run on
port 6379, which is the port we’ve configured Wireshark to capture data on.
redis-server --port 6380 to do this.
Send a few commands to your server using redis-cli.
Use redis-cli to send commands to your server.
redis-cli -p 6379 ping PONG
redis-cli -p 6379 echo key
If your redis implementation doesn’t send a valid response, you might see an error like this:
These error messages can be cryptic, and in some cases the Redis client might just hang waiting for bytes that never arrive.
Once you’ve sent a few commands, head back to Wireshark and you’ll now see some captured packets. You can inspect these to see exactly what data your implementation responded with.
Notice the “*1 $4 ping” at the bottom? That’s the PING command, encoded using the Redis protocol.
Now that you know exactly what data your Redis server is sending, you can compare it with the official redis implementation to verify that it is working properly.
Send commands using
redis-cli -p 6380 <command>.
Inspect the output in Wireshark (as mentioned in step 4) to see how the official Redis implementation differs from yours.
If everything seems correct and you’re still seeing test failures, it’s possible that the Codecrafters tester program is at fault. Please let us know at firstname.lastname@example.org if that’s the case!