1

I have a redis-server instance running, everything works fine if I try to connect to it via code e.g python. The problem is, redis-cli tool doesn't connect. Here's what I get when I run redis-cli:

Could not connect to Redis at 127.0.0.1:6379: �
not connected>
Could not connect to Redis at 127.0.0.1:6379: (
not connected>

Looking at the response, it's adding some characters after the port, in this case : � and : (

What could be the problem here? I've also tried redis-cli -h 127.0.0.1 -p 6379 but to no avail.

Note: Redis server is working fine.

  • Is there anything useful in the Redis log? – Jos Jan 16 '20 at 14:18
  • @Jos, checked, nothing in logs. Like I mentioned, redis-server works fine.The problem is with redis-cli. I can't even use it to connect to a remote redis instance – Wafula Samuel Jan 16 '20 at 20:03
  • Just to be sure, what are you passing as the host in your python. The server and client are definately on the same box right? – v25 Jan 17 '20 at 09:57
  • The extra characters must be part of the error string for that connection. See the source in http://download.redis.io/redis-stable/src/redis-cli.c It would be interesting to see the whole connection exchange. Can you run a tcpdump on port 6379? – Jos Jan 17 '20 at 10:28

1 Answers1

1

Have you verified redis-server service is actually running on localhost and listening on port 6379? Double check the service and port. Those extra characters are strange, but that's where the error message should be for the reason you could not connect. See my error below:

Could not connect to Redis at 127.0.0.1:6379: Connection refuse*  

In my case, redis-server wasn't actually running, and trying to start it via

service redis-server start

command generated errors in /var/log/redis/redis-server.log