Home FAQ How To Install And Configure Redis Server In Ubuntu

How To Install And Configure Redis Server In Ubuntu

By sk
Published: Last Updated on 2.3k views

Redis is a free, open source key-value database. It is similar to memcached but the dataset is not volatile and other datatypes (such as lists and sets) are natively supported. Redis comes with redis-cli which provides a simple command-line interface to the Redis server. This tutorial walks you through how to install Redis and configure it in Ubuntu. I tested this guide on Ubuntu 18.04 LTS server, however this guide might work on other Ubuntu/Debian-based distros.

Install Redis Server in Ubuntu

Redis Server is available in the default repositories of Ubuntu. So, you can install it using the apt-get package manager.

Run the following command to install Redis Server on your Ubuntu system:

$ sudo apt-get install redis-server

After installing, check if Redis Server service is start or not with command:

$ sudo systemctl status redis-server

Sample output would be:

● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2018-06-02 12:40:26 IST; 6s ago
Docs: http://redis.io/documentation,
Main PID: 2623 (redis-server)
Tasks: 4 (limit: 2322)
CGroup: /system.slice/redis-server.service
└─2623 /usr/bin/redis-server

Jun 02 12:40:26 ubuntuserver systemd[1]: Starting Advanced key-value store...
Jun 02 12:40:26 ubuntuserver systemd[1]: redis-server.service: Can't open PID file /var/run/red
Jun 02 12:40:26 ubuntuserver systemd[1]: Started Advanced key-value store.

Just in case, if it is not started already, you can start it as shown below.

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

To check the installed version of Redis Server, just run:

$ redis-server -v

Sample output:

Redis server v=4.0.9 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=1bc80a08306a3efd

Configure Redis Server

The default configuration file of Redis is /etc/redis/redis.conf. By default Redis listens for connections from all the network interfaces available on the server. It is also possible make it to listen to just one or multiple interfaces using the "bind" configuration directive, followed by one or more IP addresses.

To make Redis server to listen to a particular IP address, edit /etc/redis/redis.conf file:

$ sudo vi /etc/redis/redis.conf

Find the following line:


Change it as shown below.


To make it listen to multiple IP addresses, then change it like below.


Replace the IP addresses with your own values. Then, save and close the file.

Restart Redis service to apply the changes.

$ sudo systemctl restart redis-server

Test Redis Server

Connect to the Redis Server using redis-cli from command line.

$ redis-cli

Now, you're connected to your Redis server.>

From here, you can run Redis commands to test its functionality. Let us see a simple example.> set test "Welcome To OSTechNix"
OK> get test
"Welcome To OSTechNix">

To quit from Redis command prompt, type exit.> exit

To learn more about Redis usage, refer the its official documentation page.


Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More