joeferner / redis-commander

Redis management tool written in node.js
http://joeferner.github.io/redis-commander/
MIT License
3.56k stars 460 forks source link

Can't connect to localhost redis #564

Open Twisterking opened 4 months ago

Twisterking commented 4 months ago

So I have a redis-server running on localhost on my macOS machine. I have no issues connecting to it via redis-cli, but I can't get redis-commander to work.

I tried this:

docker run --rm --name redis-commander -d -p 8081:8081 ghcr.io/joeferner/redis-commander:latest

Does not work. redis-commander starts up, but it can't connect to my local redis instance. I have all standard settings - 6379 port, no username, no password ... you got it.

What am I doing wrong? I also tried this:

docker run --rm --name redis-commander -d -p 8081:8081 --env REDIS_HOSTS=local:172.17.0.1:6379 ghcr.io/joeferner/redis-commander:latest

also no success! :(

When I just run it on my host machine via $ redis-commander, the redis instance is instantly found and connected. So yeah ... I am usually really familiar with docker, so it is beyond me why there is no connection from inside the docker container to my host's redis.

I am 100% sure that e.h. 172.17.0.1 is my hosts IP from inside the container (docker inspect confirms this), there are no port issues, ... I really don't get it!

sseide commented 4 months ago

Hi, Redis Commander is running inside the container and from inside the container point of view localhost are apps running inside the same container only (exception: Kubernetes - here all container running inside the same pod). Therefor your first command tries to connect to port 6379 inside the docker container and not to your server...

Please find the real ip address of your MacOS (and not localhost / 127.0.0.1 / ::1) and make sure the Redis server is bound to this ip address. Than use the second command and replace the 172.xxx address with the ip address the Redis server is bound to. The docker container must be able to rote its traffic to this address too.

Maybe your problem is Redis listening to localhost only - check from your Mac and try to connect to the Redis server with this non-localhost address.