Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error :Could not connect to Redis at redis:6379: Name or service not known

Tags:

docker

redis

I am trying to execute the container named redis which is running right now.But the error Could not connect to Redis at redis:6379: Name or service not known. Any one please hell me to figure out the issue and fix it.

like image 357
Muneer Muhammed Avatar asked Oct 15 '15 07:10

Muneer Muhammed


People also ask

Why could not connect to Redis?

Most webmasters and web hosts that use Redis would have seen this error: Could not connect to Redis at 127.0.0.1:6379: Connection refused It is usually caused when the Redis service is stopped in the server. As part of our Server Management Services for online service providers and website owners, we have seen several other causes for this error.

How to overcome Redis port 6379 port is not allowed error?

There can be different reasons of raising the error. I am trying to provide the reason and the solution to overcome from that situation. Make sure you have installed redis-server properly. 6379 Port is not allowed by ufw firewall. The issue can be related to permission of redis user.

What ports does Redis listen to?

By default Redis server listen to the TCP port 6379. If another application is using the port or if the firewall restrictions blocks the port, it can trigger the connection refused error.

How to fix Redis is not working in Docker?

Typically, above error occurs when Redis is disable. systemctl restart redis-server systemctl enable redis-server 2. You may need to daemonize the redis-server so that docker can connect to it: Then try again the command you performed, that gives you error.


2 Answers

Naming the container doesn't alter your hosts file or DNS, and depending on how you ran the container it may not be accessible via the standard port as Docker does port translation.

Run docker inspect redis and examine the ports output, it will tell you what port it is accessible on as well as the IP. Note, however, that this will only be connectable over that IP from that host. To access it from off of the host you will need to use the port from the above command and the host's IP address. That assumes your local firewall rules allow it, which are beyond the scope of this site.

like image 164
The Real Bill Avatar answered Sep 17 '22 13:09

The Real Bill


Try below command

src/redis-cli -h localhost -p 6379
like image 38
firoz Avatar answered Sep 18 '22 13:09

firoz