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

How is Livepatch safeguarded against bad actors?

Canonical Livepatch is a security patching automation tool which supports reboot-less security updates for the…

3 hours ago

Accelerating data science with Apache Spark and GPUs

Apache Spark has always been very well known for distributing computation among multiple nodes using…

3 hours ago

Cut data center energy costs with bare metal automation

Data centers are popping up everywhere. With the rapid growth of AI, cloud services, streaming…

1 day ago

Build the future of *craft: announcing Starcraft Bounties!

Our commitment to building a thriving open source community is stronger than ever. We believe…

1 day ago

NodeJS 18 LTS EOL extended from April 2025 to May 2032 on Ubuntu

The clock was ticking: Node.js 18’s upstream End of Life (EOL) The OpenJS Foundation is…

1 day ago

Native integration now available for Pure Storage and Canonical LXD

June 25th, 2025 – Canonical, the company behind Ubuntu, and Pure Storage, the IT pioneer…

2 days ago