What this error actually tells you
This error means your program tried to reach a database called Redis at the address 127.0.0.1 (your own computer) on port 6379 (a specific communication channel), and either Redis was not running or something blocked the connection. "Connection refused" is the computer's way of saying "I got your request, but nothing is listening on that address."
Redis is a tool that stores data in memory — think of it as a very fast temporary filing cabinet that programs use to remember things between restarts. Your program expected to find it running and ready, but it was either never started, crashed, or is blocked by a firewall or network setting.
This is one of the most common errors when setting up local development environments or running applications that depend on Redis. The fix is almost always one of three things: start Redis, check that it is actually running, or verify your program is looking in the right place.
Key Takeaways
- Redis must be running as a separate service before your program can connect to it — starting your main program alone will not start Redis automatically.
- 127.0.0.1:6379 is the default address and port for Redis on your own computer; if your setup uses a different address or port, your program needs to be told about it.
- The error appears when Redis is not running, has crashed, or is blocked by a firewall or network configuration.
- You can check whether Redis is running by opening a terminal and typing a straightforward command that attempts to connect to it.
How to start Redis on your own computer
The first step is to make sure Redis is actually installed. If you have never installed it, you will need to do that before you can run it. On Mac, the easiest way is to use Homebrew (a package manager). Open Terminal and type brew install redis, then press Enter. On Windows, you can read an installer from the official Redis website or use Windows Subsystem for Linux. On Linux, use your package manager: sudo apt install redis-server on Ubuntu or Debian.
Once Redis is installed, you start it by opening Terminal (or Command Prompt on Windows) and typing redis-server, then pressing Enter. You should see output that says "Ready to accept connections" — that means Redis is now running and listening on 127.0.0.1:6379. Leave this terminal window open while your program is running. If you close it, Redis stops and your program will see the connection refused error again.
If you see an error like "command not found" or "redis-server is not recognized", Redis is not installed or not in your system path. Go back and install it using the method for your operating system.
How to check if Redis is already running
If you think Redis might already be running but your program still cannot connect, you can test the connection directly. Open a new terminal window (do not close the one running redis-server) and type redis-cli ping. If Redis is running, you will see PONG as the response. If you see "Could not connect" or "Connection refused", Redis is not running or is listening on a different address.
You can also check what is using port 6379. On Mac or Linux, type lsof -i :6379. On Windows, type netstat -ano | findstr :6379. If something is already using that port, you either have Redis running somewhere you did not expect, or another program is using the same port. If it is another program, you can either stop that program or configure Redis to use a different port.
Why your program cannot find Redis even when it is running
Sometimes Redis is running, but your program still cannot reach it. This usually means your program is looking in the wrong place. Check your program's configuration file or startup settings to see what address and port it is trying to use. If it says something other than 127.0.0.1:6379, that is the problem — either start Redis on that address and port, or change your program's configuration to point to 127.0.0.1:6379.
If your program is running inside a container (Docker) or a virtual machine, 127.0.0.1 inside the container is not the same as 127.0.0.1 on your main computer. You may need to use the container's internal network address or the host machine's actual IP address instead. Check your container or virtual machine documentation for the correct address to use.
A firewall or security software can also block the connection even if Redis is running. If you have recently installed antivirus software or a firewall, check its settings to see whether it is blocking port 6379. On Windows Defender, go to Firewall settings and look for rules that mention Redis or port 6379.
When Redis crashes or becomes unresponsive
If Redis was running but suddenly stopped responding, it may have crashed. The simplest fix is to stop it and start it again. In the terminal where redis-server is running, press Ctrl+C to stop it. Wait a few seconds, then type redis-server again to start it fresh.
If Redis keeps crashing when ready after you start it, there may be a corrupted data file or a configuration problem. Try starting it with redis-server --appendonly no to skip loading saved data. If that works, your data file is corrupted and you may need to delete it and start fresh. The data file is usually at /var/lib/redis/dump.rdb on Linux or /usr/local/var/db/redis/dump.rdb on Mac.
Setting up Redis to start automatically
If you are tired of manually starting Redis every time you restart your computer, you can set it up to start automatically. On Mac with Homebrew, type brew services start redis. On Linux, type sudo systemctl enable redis-server followed by sudo systemctl start redis-server. On Windows, you can use the Task Scheduler to run redis-server at startup, or use a third-party tool like NSSM (Non-Sucking Service Manager) to run it as a Windows service.
Once Redis is set to start automatically, you will not see the terminal window with "Ready to accept connections" anymore — it runs in the background. You can still check whether it is running by using redis-cli ping in a terminal.
Frequently Asked Questions
Does Redis need to be on my own computer, or can it be somewhere else?
Redis can be on your own computer or on another computer on your network or the internet. If it is somewhere else, the address will not be 127.0.0.1 — it will be the IP address or hostname of the other computer. Check your program's configuration to see what address it is trying to use, and make sure Redis is actually running at that address.
What if I do not want to use Redis at all?
If your program requires Redis but you do not want to run it, you have two options: find a version of the program that does not need Redis, or configure your program to use a different storage system if it supports one. Some programs let you swap out Redis for another tool like Memcached. Check your program's documentation to see what options are available.
Can I run multiple copies of Redis on the same computer?
Yes, but each one needs its own port number. Start the first one normally with redis-server (it uses port 6379). Start the second one with redis-server --port 6380. Then tell your program which port to use in its configuration. This is useful for testing or running multiple separate applications, but most people only need one Redis instance.
Why does the error say 127.0.0.1 instead of localhost?
127.0.0.1 and localhost are the same thing — they both mean "this computer". Your program uses the IP address 127.0.0.1 internally, but you will often see it written as localhost in configuration files. If your program is configured to use localhost but Redis is running on 127.0.0.1, they should still connect because they are the same address.