Loading...

Install Redis on Ubuntu

Jonas Scholz
2 min read 25. Jan. 2025

In this guide, you'll learn how to install Redis on Ubuntu and get it running properly. Whether you're setting up a development environment or preparing a production server, these instructions will help you get Redis up and running quickly and securely.

Before we begin, make sure you have:

  • An Ubuntu system (this guide works for recent versions like 20.04, 22.04, and later)
  • Terminal access with sudo privileges
  • Basic familiarity with command-line operations

Let's start with the installation process!

  1. First, we'll install the necessary tools that we'll need for adding the Redis repository:
sudo apt-get install lsb-release curl gpg
  1. Next, we'll fetch and add the Redis GPG key to verify package authenticity:
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
  1. Set the correct permissions for the GPG key file:
sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg
  1. Add the official Redis repository to your system's package sources:
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
  1. Update your package list to include the new repository:
sudo apt-get update
  1. Install Redis with this command:
sudo apt-get install redis

Once installed, Redis should start automatically. It's also set to restart at boot time, so you won't need to start it manually after reboots. However, if you find that Redis isn't starting on its own, you can enable and start it manually with these commands:

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

To check if Redis is working, you can use the Redis command-line interface (CLI). First, open a new terminal window and type:

redis-cli

This should connect you to the Redis server. To test the connection, type:

ping

If everything is set up correctly, you should see:

PONG

This confirms that Redis is running and ready to use.

If you ever need to stop or restart Redis, you can use the systemctl commands:

sudo systemctl stop redis-server
sudo systemctl start redis-server
sudo systemctl restart redis-server

And that's it! You've successfully installed Redis on Ubuntu. From here, you can explore more about using Redis, like connecting with different clients or setting it up for production use.

Welcome to the container cloud

Sliplane makes it simple to deploy containers in the cloud and scale up as you grow. Try it now and get started in minutes!