How to Install Redis on Ubuntu (22.04 & Other  Versions) – A Beginner’s Guide

Install Redis on Ubuntu

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

Redis (Remote Dictionary Server) is a fast, open-source, and in-memory key-value store used as a database, cache, and a message broker. The speed and versatility that comes with it makes it a popular choice for building scalable and high-performing applications. 

It is also highly compatible with Ubuntu, especially with the latest LTS version like 22.04. Therefore, if you need to install Redis on Ubuntu, this guide will help you with the step by step process, guiding you through the configurations, and how to find the right support. 

Whether you are a beginner or just new to Redis, you will learn how to install, configure, and manage Redis effectively. 

What is Redis & Why Use Redis on Ubuntu?

install redis on ubuntu

Redis is one of those open-source, in-memory data structures that uses a database, cache, and message broker. It does support a huge range of data types, such as strings, lists, sets, hashes, and more, which allows the developers to build fast and efficient applications. 

Since the data is stored in memory, Redis delivers a lightning-fast read and write operation. 

Why Use Redis on Ubuntu?

Redis is usually used with Ubuntu, and here is why: 

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

  • Ubuntu offers a stable, secure, and regulated environment, which makes it reliable for running services like Redis. 
  • Redis is available within Ubuntu’s official repositories and can be installed with a few commands. 
  • Ubuntu has a large user base along with a strong community that makes troubleshooting easy. 
  • Ubuntu LTS (Long-term support) versions optimal security for up to 5 years. 

Whether you’re setting up Redis for development or preparing it for production, Ubuntu offers the tools and support you need to get started smoothly.

Related Article: Easy Ways on How to Install Zoom on Ubuntu (With Troubleshooting Tips)

How To Set Up Redis on Ubuntu

To install Redis on Ubuntu, you can follow these easy stops: 

  1. Prerequisites for Installing Redis

Before you install Redis on Ubuntu, make sure that your system is compliant with: 

  • A system running Ubuntu 22.04 or another supported version (20.04, 18.04, etc.)
  • A user account with sudo privileges
  • Internet access to download packages
  1. Update Package Index and Install Dependencies

Then, you need to update your system to ensure that all the packages are up to date: 

sudo apt update

sudo apt upgrade -y

Install essential build tools and libraries, using the command: 

sudo apt install build-essential tcl -y

  1. Installing Redis on Ubuntu 22.04 (and Other Versions)

You can install Redis on Ubuntu directly from the repository: 

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

sudo apt install redis-server -y

This will install Redis and all the default configurations like the files and systemd service. 

  1. Starting and Enabling the Redis Service

After installation, launch the Redis service: 

sudo systemctl start redis

Then, enable Redis to start on system boot by running: 

sudo systemctl enable redis

Lastly, check if Redis is running:

sudo systemctl status redis

  1. Testing Redis Installation

Check if your Redis installation was successful using the Redis CLI by running: 

redis-cli

Inside the prompt, type:

ping

If Redis is working correctly, it should reply with:

PONG

Type exit to leave the CLI.

  1. Securing Redis for Production

To ensure that Redis is safe for production environments: 

  • Bind to local hosts or IPs by editing the configuration file. 
  • Set a strong password using the requirepass directive
  • Disable dangerous commands like FLUSHALL, CONFIG, and SHUTDOWN

These changes can be made in the redis.conf file:

sudo nano /etc/redis/redis.conf

  1. Configuring Redis (redis.conf Basics)

Here are the key configuration options that you might want to fit in /etc/redis/redis.conf:

  • supervised systemd – Enables integration with systemd
  • requirepass your_secure_password – Sets a password
  • bind 127.0.0.1 ::1 – Limits access to local connections
  • appendonly yes – Enables AOF persistence

After making changes, restart Redis:

sudo systemctl restart redis

  1. Enabling Remote Access (Optional)

If you want the Redis service to be accessed remotely, follow these steps: 

  1. Edit the bind address in redis.conf using bind 0.0.0.0
  2. Disable the protected-mode by protected-mode no
  1. Ensure Redis is protected with a password (requirepass).
  2. Open the port in the firewall (default port is 6379) using sudo ufw allow 6379

Uninstalling Redis from Ubuntu

If you need to un-install Redis on Ubuntu, you can safely do us with these steps: 

  1. Stop the Redis service:

sudo systemctl stop redis

  1. Uninstall the Redis package:

sudo apt remove –purge redis-server -y

  1. Remove any remaining dependencies:

sudo apt autoremove -y

  1. (Optional) Delete Redis configuration and data files:

sudo rm -rf /etc/redis /var/lib/redis

Troubleshooting Guide To Install Redis on Ubuntu

IssuePossible CauseSolution
redis-cli ping returns “Could not connect to Redis”Redis service is not runningRun sudo systemctl start redis
Redis doesn’t start on bootService not enabledRun sudo systemctl enable redis
“bind” error in logsRedis is trying to bind to an unavailable IPEdit redis.conf and set bind 127.0.0.1
“Permission denied” error when starting RedisRunning without proper privilegesUse sudo or check ownership of Redis directories
Cannot connect remotely to RedisRemote access not configuredCheck redis.conf, firewall rules, and set a password
Redis responds but doesn’t persist dataAOF or RDB persistence disabledEnable appendonly yes or save directives in redis.conf

Conclusion

Redis is one of the most powerful tools for caching, data storage, and real-time messaging. You can easily install Redis on Ubuntu, whether you are using a version 22.04 or another supported release! 

FAQs

Does Redis work on all Ubuntu versions?

Yes, Redis is compatible with most actively supported Ubuntu versions like 22.04, 20.04, and 18.04. Minor package differences may apply.

How do I enable Redis to start on boot?

Run: sudo systemctl enable redis

Is Redis secure by default after installation?

No. For production environments, it’s recommended to configure redis.conf, bind it to localhost, set a password, and disable unsafe commands.

Marium Fahim
Hi! I am Marium, and I am a full-time content marketer fueled by an iced coffee. I mainly write about tech, and I absolutely love doing opinion-based pieces. Hit me up at [email protected].
Unlock Benefits

Become a Community Member

SIMPLIFY SETUP, MAXIMIZE EFFICIENCY!
Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!