Redis MCP: ECONNREFUSED the loopback address:6379 from Docker (point REDIS_HOST correctly)
Fixes the Redis MCP server failing with connection refused when Redis runs in Docker but the server points at the default host. The server defaults to the loopback address, which inside a container is the container itself. The fix is pointing REDIS_HOST at the real Redis address. Use when Redis is reachable from the host but not from the MCP server; not for auth errors.
TL;DR: connection refused from a containerized Redis MCP server usually means it is trying to reach Redis at the loopback address, which inside the container is itself. Set REDIS_HOST to the real address: host.YOUR_HOST for Redis on your laptop, or the container/service name on a shared Docker network.
Error: connect ECONNREFUSED the loopback address:6379Fix it
- Figure out where Redis actually lives relative to the MCP server:
- Redis on your laptop, MCP server in Docker: host is
host.YOUR_HOST. - Both in Docker Compose: host is the service name, e.g.
redis. - Both on the host:
the loopback addressis correct, check Redis is running.
- Set it explicitly. Do not rely on the default:
REDIS_HOST=host.YOUR_HOST
REDIS_PORT=6379 In a client config env block, add "REDIS_HOST": "host.YOUR_HOST".
- Verify from inside the same network namespace if you can:
docker run --rm redis:7 redis-cli -h host.YOUR_HOST ping Expected: PONG.
- Restart the MCP server.
Expected: connection refused is gone.
When to use this
redis-cli pingworks on your host but the MCP server gets ECONNREFUSED.- The MCP server runs in Docker and Redis runs elsewhere.
When NOT to use this
- Both run on the same host outside Docker and it still refuses. Then Redis is not running or not listening on 6379.
- The error is NOAUTH or WRONGPASS. The connection works; auth is the problem.
Compatibility
- redis/mcp-redis in Docker / Docker Compose.
- Docker Desktop (macOS/Windows) supports
host.YOUR_HOST. On Linux, add--add-host=host.YOUR_HOST:host-gateway.
Why it happens
Every container has its own loopback interface. the loopback address inside the MCP container never leaves the container, so it can only reach a Redis running in that same container. The default REDIS_HOST=the loopback address is only correct when server and Redis share a network namespace.
Edge cases
--network=hoston Linux makes container YOURHOST equal host YOURHOST, but it does not work on Docker Desktop for Mac/Windows.- If Redis is bound to
the loopback addressin its own config, other containers cannot reach it even by service name. Bind Redis tothe all-interfaces address(with a password) for container networking. - Port mappings (
-p 6379:6379) matter for host-to-container, not container-to-container. On a shared network, use the container port directly.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.