Skip to content

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

Key points

  • localhost inside a container is the container itself.
  • bind decides which interfaces Redis listens on.
  • Protected mode rejects remote clients with no password.
  • Do not expose Redis to the internet.

What it means

A client attempted TCP to the host and port and got a rejection, so nothing is listening there. Other messages are different: "NOAUTH" means you reached it and need credentials, and a timeout suggests a firewall.

Common causes

  • Redis is stopped or crashed.
  • localhost in Docker or Compose, where the service name is needed.
  • bind 127.0.0.1 blocking remote hosts.
  • Protected mode when no password is set.
  • Wrong port or TLS port.
  • Redis unable to start after failing to load a corrupt AOF file.

Diagnose it

Test from where your application actually runs.

bash
# 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-mode

Fixes

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.

Frequently asked questions

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

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.