Troubleshooting guide
Redis connection refused: how to fix it
Nothing accepted the connection on the Redis address your application used. In containers, that address is often simply wrong.
3 min read11 sectionsUpdated
On this page
# Is it listening, and on what address?
sudo ss -ltnp | grep 6379
# Test from the application host or container
redis-cli -h redis -p 6379 ping
docker exec -it app sh -c 'nc -vz redis 6379'
# Why did it stop?
systemctl status redis --no-pager
journalctl -u redis -n 40 --no-pager
# Current bind and protected mode
redis-cli CONFIG GET bind
redis-cli CONFIG GET protected-modeFixes
Start Redis, and read the log if it will not start. In Compose, set the host to the service name: REDIS_URL=redis://redis:6379. For remote access, bind only to a private interface and set a strong password or ACL. If a corrupted AOF prevents startup, back it up first and then run redis-check-aof --fix, which may truncate the most recent writes.
Keep it private
Never answer this error by binding to 0.0.0.0 with protected mode off on a public host. Internet-exposed Redis instances are found and taken over within hours, and attackers can use its CONFIG command to write files. Use private networking, security groups or a VPN, along with ACLs. Your application should also degrade sensibly: if Redis is only a cache, a connection failure should mean slower pages rather than an error page, with a short connect timeout so that requests do not hang.
Catch it automatically
A TCP check on the Redis port plus an application-level health check shows you whether Redis is down or merely unreachable. Redis monitoring adds restarts and memory.
Why does it work on my host but not in Docker?
Inside a container, localhost refers to that container. Use the service or host name.
What is protected mode?
A safety feature that refuses remote clients when Redis has no password and no explicit bind address.
Should Redis ever be public?
No. Keep it on private networks only.
Check it now, free
- Open port checker: Is a TCP port open, closed or filtered from the internet?
Related reading
- PostgreSQL connection refused: how to fix it: Fix PostgreSQL connection refused on port 5432: server not running, listen_addresses, pg_hba.conf, Docker hostnames and firewalls, with commands for every case.
- ERR_CONNECTION_REFUSED: how to fix it: Fix ERR_CONNECTION_REFUSED in Chrome: nothing listening on the port, firewalls, wrong ports and localhost binding, with steps for visitors and for site owners.
- SSH connection refused: how to fix it: Fix "ssh: connect to host port 22: Connection refused": sshd stopped, wrong port, firewalls and fail2ban, and how to get back in when you are locked out.
- "Your connection is not private": how to fix it: Fix "Your connection is not private" (NET::ERR_CERT_*): expired or mismatched certificates, wrong device clocks, missing intermediates and Wi-Fi portals.
- Redis "max number of clients reached": how to fix it: Fix Redis ERR max number of clients reached: find leaking applications with CLIENT LIST, tune maxclients and file limits, and pool or multiplex connections.
- NET::ERR_CERT_DATE_INVALID: how to fix it: Fix NET::ERR_CERT_DATE_INVALID ("Your connection is not private"): an expired or not-yet-valid certificate, or a wrong device clock. Check, renew, reload.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.