Could not connect to Redis at 127.0.0.1:6379: Connection refused
Redis Connection refused on 127.0.0.1:6379 means nothing listens on that address and port. Check the server, the port, bind, and localhost in containers.
Could not connect to Redis at 127.0.0.1:6379: Connection refusedredis-cli tried port 6379 on 127.0.0.1, nothing was listening there, and the OS refused the connection. Redis is down, listens on another port or address, or the client sits in a different container than Redis. Password and protected-mode problems show up only after a connection succeeds, so they look different.
[1] Read the end of the message. Three variants showed up in testing:
| Ending | Meaning | Go to |
|---|---|---|
Connection refused | Nothing listening on that address/port | [2]–[5] |
Name or service not known | The -h host name did not resolve | Check the name / DNS |
DENIED … protected mode or NOAUTH after connecting | Connected, then refused | Links at the end |
$ redis-cli -h nosuchhost pingCould not connect to Redis at nosuchhost:6379: Name or service not known[2] Check that Redis is running. On the server, look at the process and listening ports (ps -ef | grep redis-server, ss -ltnp | grep redis). No process: start the service, and if it fails to start, read the Redis log. A good start ends with the listening port in the log:
1:M 27 Oct 2026 08:20:41.123 * Running mode=standalone, port=6379.1:M 27 Oct 2026 08:20:41.123 * Server initialized1:M 27 Oct 2026 08:20:41.123 * Ready to accept connections tcp[3] Check that the port is really 6379. If port was changed in the config, the default port is refused. This server listens on 6380:
$ redis-cli pingCould not connect to Redis at 127.0.0.1:6379: Connection refused$ redis-cli -p 6380 --no-auth-warning -a '<password>' pingPONGFrom inside, INFO server shows tcp_port and config_file. The config file it actually loaded is right there, so you can tell whether the file you edited is the one in use.
$ redis-cli INFO server | grep -E '^(redis_version|tcp_port|config_file):'redis_version:7.4.12tcp_port:6379config_file:/conf/bind-local.conf[4] If connections from other hosts are refused, check bind. The redis.conf shipped with the Redis source has bind 127.0.0.1 -::1, so a server started with that file accepts only loopback (the same file's comments say that with no bind directive Redis listens on all interfaces). It works locally and is refused from outside:
$ redis-cli CONFIG GET bindbind127.0.0.1 -::1$ redis-cli pingPONGThe same server from another container:
$ redis-cli -h redis pingCould not connect to Redis at redis:6379: Connection refusedTo accept remote clients, add the server's private address to bind (for example bind 127.0.0.1 -::1 192.0.2.10). A - before an address means "start even if this address is not available". The official redis.conf warns that binding to all interfaces on a host exposed to the internet is dangerous. Before you open it with bind 0.0.0.0, put a firewall and a password in place (NOAUTH Authentication required). bind is applied by editing the config file and restarting. A restart drops existing connections, and an address written without - that does not exist on the server keeps Redis from starting, so copy redis.conf first (cp -a redis.conf redis.conf.bak); if something goes wrong, restore that file (originally bind 127.0.0.1 -::1) and restart again.
[5] Make sure an app inside a container is not connecting to 127.0.0.1. In a container, 127.0.0.1 is that container itself, so Redis in a neighbouring container refuses. Connect by the Redis container's name (the service name on the same Docker network):
$ redis-cli -h 127.0.0.1 pingCould not connect to Redis at 127.0.0.1:6379: Connection refused$ redis-cli -h redis pingPONGChange app settings such as REDIS_HOST=localhost or redis://127.0.0.1:6379 to that name. In Docker Compose, the service name is the host name.
[6] After the change, run ping again from where the client really runs. PONG means the connection problem is solved and any error after this is about auth or commands. If the app host has no redis-cli, run redis-cli -h <host> -p <port> ping from a Redis image container with the same host and port the app uses.