Home Ubuntu How to Install Redis on Ubuntu 20.04/22.04

How to Install Redis on Ubuntu 20.04/22.04

What is really the hype behind Redis? Redis has created a reputation for itself as the go-to data store. It is attributed as a key-value, in-memory, and open-source data store. These attributes make Redis an ideal message broker, cache, and database candidate/application.

Also, Redis’ resume illustrates its support for numerous data structures like Sets, Hashes, Lists, and Strings. Through features like automatic partitioning and Redis Sentinel, multiple Redis nodes and Redis Cluster provide high Redis availability.


Be a sudoer/root user on the Ubuntu operating system you are using.

Installing Redis on Ubuntu

Make sure your Ubuntu operating system is up-to-date as it helps with the performance optimization of installed and yet-to-be-installed application packages.

$ sudo apt update && sudo apt upgrade -y 

Next, run the following command to install Redis on your Ubuntu system.

$ sudo apt install redis-server -y
Install Redis in Ubuntu
Install Redis in Ubuntu

Once the installation process completes, confirm Redis installed version on your system.

$ redis-server --version
Check Redis Version in Ubuntu
Check Redis Version in Ubuntu

Next, enable and check Redis’s status to be sure it is up and running.

$ sudo systemctl enable redis-server 
$ sudo systemctl status redis-server 
Check Redis Status in Ubuntu
Check Redis Status in Ubuntu

Configuring Redis on Ubuntu

Now that we have installed and confirmed that Redis is up and running, it is time to implement some important configurations. The default installation of Redis does not permit remote connections. Redis’ default configuration only permits localhost ( connections on the machine hosting it.

You do not need to enable remote access/connection on your Redis configuration if you have a single server setup. However, if for some reason a separate/remote server setup is running Redis, you will need to configure it to handle remote connections.

The following command should open Redis’ main configuration file on your Ubuntu system:

$ sudo nano /etc/redis/redis.conf 

Trace the following sections on the file:

Redis Configuration File
Redis Configuration File

This section demonstrates how to bind Redis to all or specific remote machines’ IP addresses. For instance, if we want any remote user to be able to access this Redis server, we will edit out or comment on the line bind ::1 and replace it with bind ::1.

Enable Redis Remote Connection
Enable Redis Remote Connection

For the implemented configuration changes to be effective, restart the Redis server.

$ sudo systemctl restart redis-server 

Next, verify that all Redis is listening to its associated interfaces.

$ ss -an  | grep 6379 
Check Redis Listening State
Check Redis Listening State

Since Redis communicates via port 6379, your firewall (if active) should be configured to allow traffic through this port.

$ sudo ufw allow 6379/tcp
$ sudo ufw reload 
$ sudo ufw status 

Testing Redis Remote Connection

On the remote machine that wishes to connect to the Redis server, install redis-tools to facilitate this client-to-server communication.

$ sudo apt install redis-tools -y 

Next, we will now use the redis-cli utility to ping the Redis server via IP address.

$ redis-cli -h ping
Test Redis Remote Connection
Test Redis Remote Connection

The output PONG confirms that the two remote computers can communicate with one another.

This article has walked us through the installation, configuration, and testing of the Redis server on Ubuntu. For a more thorough Redis configuration guide, reference the file /etc/redis/redis.conf.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

1 thought on “How to Install Redis on Ubuntu 20.04/22.04”

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.