Redis server disconnects after connection is established

4,085 views
Skip to first unread message

Nishant Dani

unread,
May 28, 2018, 12:39:48 AM5/28/18
to Redis DB
I am running redis-server inside a docker container.  It is running on 127.0.0.1 port 6379. 

In Container:
 I am able to connect to the redis-server when within the container and process commands without a problem.  

From Host:
When I do redis-cli from the host to the container using redis-cli monitor it gives 

Error: Server closed the connection.


If I just do redis-cli , it gives the prompt;

127.0.0.1:6379> 

127.0.0.1:6379> set www yee

Error: Server closed the connection

This seems that the docker has the right port exposed and the docker port mapping is working.  The failure is not at establishing the connection, but the connection gets terminated soon after.


From another container on the same docker network:

    redis.on('error', function(err) {

        logger.error('Redis error: ' + err);

    } );


Redis error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379


So any command sent to the redis-server the redis-server closes the connection.

My redis.conf file has protected-mode no.

The logging is set to debug but there is no information on the log either that shows that a connection was attempted and declined.

If there are any tips for debugging this would be very helpful;



Dvir Volk

unread,
May 28, 2018, 4:21:42 PM5/28/18
to redi...@googlegroups.com
What does the redis log show?
"Server closed the connection" is how redis crashing looks from the client perspective. It might be something else but that's the first place I'll look. Maybe not enough memory allocated to the container or something similar?

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Nishant Dani

unread,
May 28, 2018, 4:30:10 PM5/28/18
to Redis DB
The redis log was not showing anything.  However I did managed to figure out the problem.

Redis was not listening on the right interface.  When I create a docker network a new interface is created for the network for each container and this interface has its own IP address.   Redis.conf has a line which defines which interface(s) redis will listen on.   I commented out the line so that it will listen on all the interfaces.  Once I did that I am now able to connect.  So it appears the connection was being refused because redis does not know it is in a container and it needs to listen to the container interface.  So I opened it up to listen on all interfaces.

# bind 127.0.0.1 ::1
Reply all
Reply to author
Forward
0 new messages