Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

redis-cli says Connection refused on a Mac with Homebrew

ErrorCould not connect to Redis at 127.0.0.1:6379: Connection refused

Short answer

Connection refused means nothing is listening on that port. After brew install redis the server is not started for you. Start it as a background service with brew services, or run redis-server in a terminal, then test with redis-cli ping. If it still refuses, check the port and the bind line.

  • Applies to Redis 8, macOS 15, Homebrew 4
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask Homebrew whether the Redis service is running.

    brew services info redis
  2. 2Match what you see, then jump to its fix

    1. 1brew services info redis shows Running with a cross, or no service line.The server was installed but never startedFix
    2. 2brew services start prints Successfully started, but redis-cli still refuses a few seconds later.The service starts and stops againFix
    3. 3pgrep shows redis-server, but redis-cli to the default address refuses.Redis runs on another port or is bound to a different addressFix

What does the error look like?

  • Could not connect to Redis at 127.0.0.1:6379: Connection refused

Cause 1 of 3

The server was installed but never started

1Check

The Homebrew package installs the binaries only. Start it yourself, in the foreground to see logs, or as a launchd service.

brew list redis
pgrep -l redis-server

2Fix

Start it as a background service that also restarts at login. For a quick test, run redis-server in a terminal instead and stop it with Ctrl-C.

brew services start redis
# or, in the foreground
redis-server

3Verify

The server answers.

redis-cli ping

Confirmed by redis.io

Did this fix it?

Cause 2 of 3

The service starts and stops again

1Check

Run the server in the foreground. A bad config line or a port in use is printed on the console and then Redis exits.

brew services stop redis
redis-server

2Fix

Fix the line the console names. If the port is taken, find the other process or give Redis another port in its config.

lsof -nP -iTCP:6379 -sTCP:LISTEN

3Verify

Start the service again and ping.

brew services start redis
redis-cli ping

Confirmed by redis.io

Did this fix it?

Cause 3 of 3

Redis runs on another port or is bound to a different address

1Check

A server started with --port or a bind line in redis.conf will not answer on 127.0.0.1:6379. Ask the process what it listens on.

lsof -nP -iTCP -sTCP:LISTEN | grep redis

2Fix

Point the client at the real address, or change the config and restart.

redis-cli -h 127.0.0.1 -p 6380 ping

3Verify

The reply is PONG.

redis-cli -p 6380 ping

Confirmed by redis.io

Did this fix it?

How do I stop it coming back?

  • Use brew services for a dev server you keep, so it comes back after a reboot.
  • Put the host and port in one environment variable that both the app and redis-cli read.
  • Run one Redis per port; stop the old one before you start another.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Databases

node-redis throws ConnectionTimeoutError on connect

Redis Client Error ConnectionTimeoutError

node-redis raises ConnectionTimeoutError when the socket does not connect within socket.connectTimeout, which is 5000 ms by default.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.