Redis "Connection refused" on port 6379: how to fix it
Could not connect to Redis at 127.0.0.1:6379, ECONNREFUSED, Error 111: Redis is not running, listening elsewhere or unreachable from a container. Check each cause in order.
· 5 min read · By the Spot Downtime team
The message depends on the client, but the problem is the same:
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Error: connect ECONNREFUSED 127.0.0.1:6379
redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused."Connection refused" means the machine at that address answered, but nothing was listening on that port. That rules out a lot: the network path works. Redis is either not running, listening on a different address or port, or you are connecting to the wrong machine. The general version of this error is in ERR_CONNECTION_REFUSED.
Refused or timed out?
Step 1: is Redis running?
redis-cli ping # PONG means it is up
sudo systemctl status redis-server # Debian/Ubuntu (redis on RHEL/Fedora)
sudo journalctl -u redis-server --since "1 hour ago"If it is stopped, the log usually says why. Common reasons:
- Killed for memory. Redis holds everything in RAM. Without a
maxmemorylimit it can grow until the kernel kills it. Look for an OOM kill indmesg, and see Linux out of memory. - Config error after an edit. Redis refuses to start on an unknown or invalid directive and logs the line number.
- Cannot write its data directory. Wrong permissions on
/var/lib/redisor a full disk. See no space left on device.
Step 2: what address and port is it on?
sudo ss -ltnp | grep redisCompare the output with what your app connects to. By default Redis listens on 127.0.0.1:6379 and [::1]:6379 only, set by bind in redis.conf. That causes two common mismatches:
- The app runs on a different machine and connects to the server's IP, but Redis only listens on localhost. Change
bindto include the private interface address, and set a password. - Redis runs on a non-default port, or there are several instances, and the app uses 6379.
With protected-mode yes (the default) and no password set, Redis also rejects clients that are not on localhost. That produces a DENIED error rather than a refusal, but it often shows up right after you fix bind.
Step 3: in Docker, localhost is the container
This is the most common cause in containerized apps. Inside a container, localhost means that container itself, not the host and not the Redis container next to it. Connect using the Compose service name instead:
services:
app:
environment:
REDIS_URL: redis://redis:6379 # the service name, not localhost
depends_on:
redis:
condition: service_healthy
redis:
image: redis:7
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5sThe health check matters too. Without it, the app can start before Redis is ready, get refused on its first connection and crash. If the app container then restarts over and over, see Docker container keeps restarting.
Kubernetes
Connect to the Service name (redis.default.svc.cluster.local), and check that the Service selector matches the Redis pod's labels. A Service with no ready endpoints refuses connections.
Related errors that are not refusals
ERR max number of clients reached: Redis is up but atmaxclients(10000 by default). Usually a connection leak in the app.MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk: a background save failed, often from a full disk or memory pressure, and Redis now rejects writes.OOM command not allowed when used memory > 'maxmemory': the memory limit is reached and the eviction policy isnoeviction.
Monitor Redis without exposing it
Redis should not be reachable from the public internet, so do not open 6379 just to monitor it. Instead, add a health endpoint to your app that runs PING against Redis and returns an error status if it fails, and point a website monitor at it. That catches a stopped Redis, a bad bind after a config change and a wrong hostname after a deploy, and it tests the path your app actually uses. If Redis runs on a host you manage, a server monitor shows the memory growth that usually comes before an OOM kill. For services that are meant to be reachable, a TCP port check catches refused connections directly.
Get new guides by email
Practical posts on monitoring, outages, error fixes and on-call, when they're published. No spam.
Keep reading
- Servers · HTTP errors · Troubleshootingnginx "Too many open files" (24) error: how to fix itnginx logs accept4() failed (24: Too many open files) when it hits its file descriptor limit. How to check the real limit, raise it with systemd and nginx, and avoid it.November 26, 2026 · 6 min read
- Servers · TroubleshootingPostgreSQL "FATAL: sorry, too many clients already": causes and fixesPostgres refuses new connections once max_connections is reached. How to find idle and leaked sessions, end them safely, add PgBouncer and size the limit so it stops happening.November 25, 2026 · 6 min read