How to Install and Configure Redis on Ubuntu 20.04

How to Install and Configure Redis on Ubuntu 20.04

Redis is the storage of key value data in open source. It can be used as a database, cache and message, and supports various data structures such as Strings, Hashes, Lists, Sets, and more. Redis provides high availability through Redis Sentinel and automatically partitions on several Redis nodes with Redis Clusters.

This tutorial explains how to install and configure Redis on Ubuntu 20.04.
Install Redis on Ubuntu 20.04

Installing Redis on Ubuntu is an easy process.

Version 5.0.x is included in the default Ubuntu 20.04 repository. To install it run the following command as root or as a user with sudo rights:
sudo apt update
sudo apt install redis-server

After the installation is complete, the Redis service will start automatically. To check service status, enter the following command:

sudo systemctl status redis-server

You should see something like this:

Output :

redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-06-06 20:03:08 UTC; 10s ago

Service reductions will fail to start if IPv6 is disabled on your server.

There she is. You have installed and run Redis on your Ubuntu 20.04 server.

Configure Remote Access Redis

By default, the Redis server does not accept remote connections. You can connect to Redis only from (localhost) – the machine where Redis is running.

If you use a single server setting, where the client is connected to the database also runs on the same host, you should not enable remote access.

To configure Redis to accept remote connections, open the Redis configuration file with your text editor:

sudo nano /etc/redis/redis.conf

Find the line that starts with bind :: 1 and comment.

# bind ::1

If your server has a private IP, and you want Redis to only be reached from the private network instead of commenting on the phone, the private IP address is after

Save the file and restart the Redis service for the changes to take effect:

sudo systemctl restart redis-server

Use the following command to verify that redis is listening on all interfaces on port 6379:

ss -an | grep 6379

You will see something like below. means all IPv4 addresses on the machine.

Output :

tcp  LISTEN 0   511*
tcp  LISTEN 0   511      [::]:6379      [::]:*  

Next, you need to configure your firewall to enable traffic from TCP port 6379.

Usually you want to allow access to the Redis server only from certain IP addresses or IP ranges. For example, to allow connections only from the subnet, you will run the following command:

sudo ufw allow proto tcp from to any port 6379

Make sure your firewall is configured to accept connections only from trusted IP ranges.

At this point, you should be able to connect to Redis on TCP port 6379 from a remote location.

To verify that everything is set up correctly, you can try to ping the Redis server from your remote machine using the redis-cli utility:

redis-cli -h <REDIS_IP_ADDRESS> ping

The command must return a response from PONG:

Output :



We have shown you how to install Redis on Ubuntu 20.04. To find more information about managing your Redis installation, visit the Redis documentation page.

If you experience problems or get feedback, leave a comment below.

Related posts

How to Install and Use a Curl on Ubuntu 20.04


How to Install TensorFlow on CentOS


How to Install Ruby on Ubuntu 20.04


How to Set Up an iSCSI Storage Server on Ubuntu 20.04 LTS


How to Install Ubuntu on a Raspberry Pi


How to Install and Use PHP Composer on Debian 10


How to Change the Time Zone in Ubuntu 20.04


How to Install Apache Cassandra on CentOS 8


How to Install and Configure Apache Hadoop on Ubuntu 20.04