Categories About Us Contact Us Become a Member

How to fix Redis connection refused and unknown host errors

This means the client cannot reach the Redis server: the address is wrong, the server is not running or bound to that interface, or a firewall is blocking the port. Jump to your situation below or work through the methods in order.

By Neeraj Singh ~6 min Updated Jun 2026 88% found this helpful
Error message
ConnectionRefusedError / UnknownHostException connecting to host:6379.
Summary

ConnectionRefusedError and UnknownHostException mean the client could not establish a network connection to Redis. Connection refused means it reached the host but nothing accepted on the port: Redis is not running, is bound to a different interface (for example only 127.0.0.1), or the port is wrong. Unknown host means the hostname did not resolve at all. A firewall blocking port 6379 produces a refusal or timeout too. The fix is to verify the host and port the client uses, confirm the Redis server is running and bound to an interface the client can reach (the bind and protected-mode settings), and ensure the firewall allows the port. A quick redis-cli -h host -p port ping from the application server pinpoints where the path breaks.

What this error means

Before any command runs, the client must open a TCP connection to Redis. Connection refused means the network reached the host but no service accepted on that port, so either Redis is not listening there or the port is wrong. Unknown host means the name never resolved to an address at all.

So this is purely a connectivity problem, not a Redis data issue. The chain is: the name resolves, the host is reachable, Redis is running and listening on the right interface and port, and the firewall permits it. Testing that chain with a ping from the app server shows exactly which link is broken.

Common causes

The Redis server is not running.
The host or port in the client is wrong.
Redis is bound only to localhost, not the client's interface.
A firewall is blocking port 6379.
The hostname does not resolve (unknown host).
Expert insight

“Connection refused and unknown host are pure networking, Redis has not even had a chance to say no to a command, the client cannot get a socket. I walk the chain from the app server: does the name resolve, can I reach the host, is Redis actually running and listening on the right interface, and is port 6379 open in the firewall. A single redis-cli -h host -p port ping usually tells me exactly which link is broken. The classic gotcha is Redis bound to 127.0.0.1 only.”

How to fix it

Method 1

Confirm Redis is running

1Check the Redis service or process is up on the server.
2Test locally on the host:
redis-cli ping
3A PONG confirms Redis is listening there.
Method 2

Verify the host and port

1Confirm the client uses the correct host and port (default 6379).
2Test from the app server:
redis-cli -h yourhost -p 6379 ping
3Fix any mismatch in the connection config.
Method 3

Check the bind and protected-mode settings

1If Redis is bound only to 127.0.0.1, remote clients are refused. Set bind to an interface they can reach, and review protected-mode.
2Restart Redis after changing redis.conf.
3Secure it with a password if exposing beyond localhost.
Method 4

Open the port in the firewall

1Allow inbound TCP on the Redis port (6379) between the client and server.
2Check host firewalls and cloud security groups.
3Then retry the connection.
Method 5

Resolve the hostname

1For unknown host, confirm the hostname resolves (try the IP address directly).
2Fix DNS or use the correct host entry.
3Then reconnect.

Connection refused and unknown host are connectivity problems. Confirm Redis is running and listening, verify the host and port, and make sure Redis is bound to an interface the client can reach (not just 127.0.0.1) with the firewall open on 6379. A redis-cli ping from the app server shows which link is broken.

Frequently asked questions

What causes Redis connection refused?
The client reached the host but nothing accepted on the port: Redis is not running, is bound to a different interface such as localhost only, or the port is wrong. A firewall blocking 6379 can also cause it.
What does unknown host mean?
It means the hostname did not resolve to an IP address. The name is wrong or DNS cannot resolve it. Test with the IP address directly and fix the DNS or host entry.
How do I diagnose it?
From the application server run redis-cli -h yourhost -p 6379 ping. Where it fails, name resolution, reachability, or refusal, tells you which part of the connection chain is broken.
Why does Redis refuse remote clients?
Often because it is bound only to 127.0.0.1 or protected-mode is on. Set bind to an interface the client can reach and configure a password, then restart Redis.
Could a firewall be blocking it?
Yes. A host firewall or a cloud security group blocking inbound TCP on 6379 produces a refused or timed-out connection. Allow the port between the client and server.
Is it safe to expose Redis remotely?
Only with protection. Set a password (requirepass or ACLs), bind to trusted interfaces, and restrict the firewall to known clients. Never expose an unauthenticated Redis to the internet.

Still not working?

If ping works from the server itself but not from the app host, the block is between them, typically a security group, a VPC route, or protected-mode; comparing a local redis-cli ping with a remote one isolates whether it is Redis or the network. You can also submit your error to us for a tailored fix.

Was this fix helpful? Thanks for your feedback!