How to Install Redis on Ubuntu Linux

This post shows students and new users step to install and configure Redis on Ubuntu Linux. Redis is an in-memory key-value and data store that is commonly used as database to store data structures such as strings, hashes, lists, sets, sorted sets with range queries, etc.

At a higher level of implementation, it can also provide high availability via Redis Sentinel including monitoring, notifications automatic failover and partitioning across multiple Redis nodes.

If you want to speed up your dynamic applications or websites, using Redis to cache and return frequently requested items may help. Redis is commonly implemented with WordPress, Drupal and other PHP based dynamic web applications.

Also, for students and new users learning Linux, the easiest place to start learning is on Ubuntu Linux. Ubuntu is the modern, open source Linux operating system for desktop, servers and other devices.

Ubuntu is a great Linux operating system for beginners.

To get started installing Redis on Ubuntu Linux, follow the steps below.

How to install Redis on Ubuntu Linux

This post assumes that your account on the server is capable of running with administrative privileges. That means you can run the sudo process.

Redis is available in Ubuntu default repositories. However, the version that comes with Ubuntu might not necessarily be the latest. If you need to install Redis latest version, then add its repository and install from there.

Installing Redis on Ubuntu is pretty straightforward. Simply run the commands below to install it on Ubuntu Linux.

sudo apt update
sudo apt install redis-server

After running the above commands, Redis server should be installed and ready to use. The commands below can be used to stop, start and enable Redis Server to automatically start up everytime the system boots up.

sudo systemctl stop redis-server
sudo systemctl start redis-server
sudo systemctl enable redis-server

To verify if the server is running, run the commands below

sudo systemctl status redis-server

That should display the status of the Redis Server service:

redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-11-29 09:02:30 CST; 15s ago
 Main PID: 26589 (redis-server)
    Tasks: 4 (limit: 4674)
   CGroup: /system.slice/redis-server.service
           └─26589 /usr/bin/redis-server

This is how you know Redis is running

How to configure Redis on Ubuntu Linux

Now that the server is installed and verified, use the steps below to configure for remote login and adjust Ubuntu firewall.

By default, Redis doesn’t allow access from remote locations ( access from different server/client). All access is restricted to the local host of the server it is installed on. ( example:

In most environments, Redis Server and the applications it supports are running on a single server. In this situation, no remote access is necessary, since all the communications are done on the single host computer.

However, if both the Redis server and applications using it are on separate hosts, then remote access will be required.

To allow remote access, open Redis configuration file by running the commands below:

sudo nano /etc/redis/redis.conf

Then change the highlighted line as shown below. basically replacing with all zeros ( ) or restrict access to a specific host IP that will need access to Redis.

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind ::1

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.

Save the file and exit.

After making the changes to the file, restart Redis service.

sudo systemctl restart redis-server

Verify that Redis is listening for all connections on by running the commands below:

ss -an | grep 6379

You should get an output as show below:

tcp  LISTEN 0      128   *                                   
tcp  LISTEN 0      128      [::1]:6379                [::]:*

If you’re also running Ubuntu firewall, simply add the policy below to allow all hosts on your subnet ( ) access to the Redis server and port number.

sudo ufw allow proto tcp from to any port 6379

That should do it.

To test if Redis hosted on IP address is responding to remote hosts. type the commands below from the remote server.

redis-cli -h ping

The Redis sever should respond with a pong

If you receive a correct reply, then all is done.


This post showed you how to install and Redis on Ubuntu Linux. If you find any error or have something to add, please use the comment form below.