Redis is an open-source and in-memory key-value store. It can be used as database, message broker or as a cache and supports different data structures like strings, lists, sets, maps, spatial indexes, and bitmaps. Redis supports wide languages with flexibility and high performance. In this guide, we will show how to install and configure Redis on a CentOS 8.
- Before you start to install, you must login as root or non-root user account with sudo privileges
- IPv6 should be enabled on your server otherwise Redis service will fail to start.
Install Redis on CentOS
Redis version 5.0.x is included in the default CentOS 8 repositories. Run the following commands to install:
sudo dnf install redis-server
This will install Redis and its dependencies. After completion of installation, Redis service need to be enable and start by typing:
sudo systemctl enable --now redis
You can verify that Redis server is running using below command:
sudo systemctl status redis
It will show below output:
● redis.service - Redis persistent key-value database Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/redis.service.d └─limit.conf Active: active (running) since Sat 2020-04-11 12:24:14 UTC; 57s ago
That’s it! Redis is ready to use on your CentOS 8 server.
Enable Redis Remote Access
By default, Redis is configured to listen on localhost only. You can connect to the Redis server only from the same machine where its service is running.
If you want to configure Redis to accept remote connections, open the Redis configuration file with your text editor using below command:
sudo nano /etc/redis.conf
Now find the line starting with
bind 127.0.0.1 and your server private ip address after
For example, your server’s private ip is
192.168.1.96 then it should look like below:
bind 127.0.0.1 192.168.1.96
Save and close the file.
You should restart the Redis service for changes to take effect:
sudo systemctl restart redis
Run the below command to verify:
ss -an | grep 6379
It should show as below output:
tcp LISTEN 0 128 192.168.1.96:6379 0.0.0.0:* tcp LISTEN 0 128 127.0.0.1:6379 0.0.0.0:*
If your are using firewall, you’ll also need to add a firewall rule to enable traffic from your remote machines on TCP port
6379. Run below command to allow connections:
sudo firewall-cmd --new-zone=redis --permanent
sudo firewall-cmd --zone=redis --add-port=6379/tcp --permanent
sudo firewall-cmd --zone=redis --add-source=192.168.1.0/24 --permanent
sudo firewall-cmd --reload
The above commands will create a new zone with name redis which allows access from private network. Now the Redis server will accept remote connections on TCP port 6379.
Make sure that your firewall is configured to accept connections only from trusted IP ranges.
To test that Redis is functioning correctly, connect to the server using redis-cli utility by pinging the Redis server from your remote machine:
redis-cli -h <REDIS_IP_ADDRESS> ping
You should see exact below output:
You can exit the redis-cli shell by typing:
This guide shown you how to install Redis on CentOS 8. To find more information about how to manage your Redis installation, visit the Redis documentation page.
If you have any questions, feel free to leave a comment.