How to Install and Configure Redis on Debian 10 Linux
3 min read
Redis is an open-source in-memory key-value data store. It can be used as a database, cache, and, message broker and supports various data structures such as Strings, Hashes, Lists, Sets, and more. Redis provides high availability via Redis Sentinel, and automatic partitioning across multiple Redis nodes with Redis Cluster.
In this tutorial, we will cover how to install and configure Redis on a Debian 10, Buster.
Installing Redis on Debian
Redis version 5.0.x is included in the default Debian 10 repositories. To install it run the following commands as root or user with sudo privileges :
sudo apt update
sudo apt install redis-server
The Redis service will start automatically when the installation finishes. You can verify it by typing:
sudo systemctl status redis-server
The output should look something like this:
● redis-server.service - Advanced key-value store Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2019-11-28 14:15:23 PST; 27s ago Docs: http://redis.io/documentation, man:redis-server(1) Main PID: 2024 (redis-server) Tasks: 4 (limit: 2359) Memory: 6.9M CGroup: /system.slice/redis-server.service └─2024 /usr/bin/redis-server 127.0.0.1:6379
That’s it! Redis is installed and running on your Debian 10 server, and you can start using it.
Configure Redis Remote Access
By default, Redis is configured to listen on localhost only. You can connect to the Redis server only from the machine where the Redis service is running.
If you are using a single server setup, where the client connecting to the database is also running on the same host, you should not enable remote access.
To configure Redis to accept remote connections open the Redis configuration file with your text editor:
sudo vim /etc/redis/redis.conf
for a line that begins with
bind 127.0.0.1 ::1 and comment it.
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES # JUST COMMENT THE FOLLOWING LINE. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # bind 127.0.0.1 ::1
Save the file and close the editor.
Restart the Redis service for changes to take effect:
sudo systemctl restart redis-server
netstat to verify that Redis is listening
on all interfaces on port
ss -an | grep 6379
You should see something like below:
tcp LISTEN 0 128 0.0.0.0:6379 0.0.0.0:* tcp LISTEN 0 128 [::]:6379 [::]:*
You’ll also need to add a firewall rule that enables traffic from your remote machines on TCP port
Assuming you are using
to manage your firewall, and you want to allow access from the
192.168.121.0/24 subnet, you would run the following command:
sudo ufw allow proto tcp from 192.168.121.0/24 to any port 6379
Make sure your firewall is configured to accept connections only from trusted IP ranges.
Once done, use the
redis-cli utility to test the connection by pinging the Redis server from your remote machine:
redis-cli -h <REDIS_IP_ADDRESS> ping
The command should return a response of
We have shown you how to install Redis on Debian 10. To find more information about how to manage your Redis installation, visit the Redis documentation page.