Categories: UbuntuUbuntu 20.04

How to Install and Use Redis on a Ubuntu 20.04 Server

This article was contributed by the folks at RackNerd – a provider of shared hosting, reseller hosting, VPS hosting, dedicated servers, DRaaS, colocation, and more. If you are looking for a VPS with full root access to set up Redis on, be sure to review their latest LowEndBox special offers here.

Redis, or Remote Dictionary Server, was created by Salvatore Sanfilippo in 2009. It is an open-source project and provides an in-memory data structure platform. It implements a key-value distributed database supporting various types of data, such as sets, bitmaps, streams, and spatial indexes. The Redis is popularly used as a cache, message broker, and database.

Today, we will see how you can install and use the Redis software on your Ubuntu 20.04 system.

  1. Requirements

This tutorial is for Ubuntu 20.04, so make sure your operating system is running Ubuntu 20.04. Also, root access to the system is required before we proceed.

  1. Install Redis

It is an easy job to get Redis installed on your system because it is included in the repositories of Ubuntu 20.04.

Run the following commands to get Redis installed:

sudo apt update

sudo apt install redis-server

After the installation is done, Redis will automatically start running in the background. To make sure that the installation was successful, run the next command:

sudo systemctl status redis-server

If the installation were completed successfully, you would see the Redis server’s status as the output.

In case Redis is installed properly, but it fails to start, make sure that IPv6 is disabled on the server.

  1. Configuring remote access

By default, you can only connect to Redis through the local host at 127.0.0.1. However, you can also enable remote access for Redis.

To enable remote access, you need to open the config file for Redis. You can do this by the following command:

sudo nano /etc/redis/redis.conf

Now, find the line that says, “bind 127.0.0.1 ::1” and put a “#” before it to comment that line.  You can now save the file and restart the Redis service by running this command.

sudo systemctl restart redis-server

To confirm that remote access has been configured, run the following command.

ss -an | grep 6379

If the output displays 0.0.0.0, it means that it is listening to all IP addresses on port 6379.

  1. Configure firewall

Now that we have configured the remote access for Redis. We need to configure the firewall for port 6379 so that incoming connections are allowed. Run the following command to enable traffic for Redis.

sudo ufw allow proto tcp from 192.168.111.0/24 to any port 6379

Make sure that you replace “192.1.168.111.0/24” with the IP address of your remote server. The firewall only allows traffic from this IP address.

To verify the remote access, you can run the following command on your remote machine:

redis-cli -h ping

If everything is working properly, you will see the output that says “PONG”.

Thanks for reading! Please leave any questions or feedback below.

The post How to Install and Use Redis on a Ubuntu 20.04 Server appeared first on Low End Box.

Ubuntu Server Admin

Recent Posts

Ubuntu MATE 25.04 Release Notes

Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

4 hours ago

Ubuntu Weekly Newsletter Issue 887

Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

1 day ago

How we ran an effective sprint to refresh our website, Part 1

A core goal of our design team at Canonical is to create a space where…

2 days ago

OpenStack Installation on a Single Node

OpenStack is a free and open software that allows different people and organizations to build…

5 days ago

What is OpenStack? A Fresh Look From a Clear Mind

As expected, a simple definition should answer this question, but most times, definitions seem to…

5 days ago

Software development for the connected car: on the safe side with Anbox Cloud

Today, Android Automotive OS (AAOS) is the preferred operating system for in-vehicle infotainment among major…

6 days ago