Discussion:
[redis-db] Redis server disconnects after connection is established
Nishant Dani
2018-05-28 00:40:38 UTC
Permalink
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;
--
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+***@googlegroups.com.
To post to this group, send email to redis-***@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
Dvir Volk
2018-05-28 20:21:20 UTC
Permalink
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?
Post by Nishant Dani
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;
--
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
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to redis-***@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
2018-05-28 20:30:09 UTC
Permalink
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
Post by Dvir Volk
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?
Post by Nishant Dani
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;
--
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
<javascript:>.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to redis-***@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
Loading...