Last updated: Apr 5, 2024
Reading time·4 min

6379 port is not blocked by your firewallThe error "Could not connect to Redis at 127.0.0.1:6379: Connection refused" occurs when you try to connect to your Redis server without having started it first.
To resolve the issue, open your terminal and run the redis-server connect to
start your Redis server before connecting to it.

Here is the complete error message.
Could not connect to Redis at 127.0.0.1:6379: Connection refused not connected>
Open your terminal and run the following command to start your Redis server.
redis-server

If you are on Windows, you might have to cd into the Redis directory before
issuing the redis-server command.
cd "C:\Program Files\Redis" redis-server
If you want to start the Redis server in the background, issue the following command instead.
redis-server &

You can also try to run the command with the --daemonize flag if that didn't
work.
redis-server --daemonize yes

Run the redis-cli command to verify the Redis server has started.
redis-cli set name "bobby hadz" get name

You can also use the redis-cli ping command to verify that your Redis server
is running.
redis-cli ping

If you get a PONG response back, then the issue is resolved.
If you get a permissions error when running the redis-server command on macOS
or Linux, rerun the command with sudo.
sudo redis-server # or sudo redis-server --daemonize yes
Make sure you've installed Redis.
brew install redis
If you are on macOS and the issue persists, try using Homebrew to start your Redis server.
brew services start redis
/usr/local/etc/redis.conf.cat /usr/local/etc/redis.conf
/usr/local/etc/redis.conf, then copy the
default Redis config file over.cp /usr/local/etc/redis.conf.default /usr/local/etc/redis.conf
/usr/local/var/db/redis directory
on your machine.mkdir -p /usr/local/var/db/redis
brew services restart redis
Make sure you have Redis installed.
# prerequisite package sudo apt install lsb-release # add the repository to the apt index curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list # install Redis sudo apt-get update sudo apt-get install redis
You can also install Redis from Snapcraft.
sudo snap install redis
If you are on Linux, run one of the following commands to start your Redis server.
sudo service redis start # or sudo service redis-server start # or sudo systemctl start redis # or sudo systemctl start redis-server.service

You can also try to restart your Redis server.
sudo service redis restart # or sudo systemctl restart redis # or sudo service redis-server restart # or sudo systemctl restart redis-server.service
If you get an error when starting your server, issue the following command
ps aux | grep redis

The command will return the process ID of Redis.
Run the following command to stop the process.
kill -9 <YOUR_PROCESS_ID>
In my case, the process ID is 1014628, so I would issue the following command.
kill -9 1014628
After you stop the process, start your Redis server with one of the following commands.
sudo service redis start # or sudo service redis-server start # or sudo systemctl start redis # or sudo systemctl start redis-server.service
6379 port is not blocked by your firewallIf the issue persists, make sure that the 6379 port is not blocked by your
firewall.
Open your terminal and run the following command.
sudo ufw allow 6379
If the issue persists, make sure that your user has the necessary permissions to read, write and execute Redis files.
Your user should have access to the files in the following directories:
/etc/redis/run/redis/var/log/redis/var/lib/redisIf you need to change the permissions of the directories to the current user, run the following commands.
sudo chown -R redis:redis /etc/redis. sudo chown -R redis:redis /run/redis sudo chown -R redis:redis /var/log/redis sudo chown -R redis:redis /var/lib/redis
Try to restart your Redis server after making the change.
sudo service redis start # or sudo service redis-server start # or sudo systemctl start redis # or sudo systemctl start redis-server.service
If you get the error MISCONF Redis is configured to save RDB snapshots, click on the link and follow the instructions.