How to Install Redis on Ubuntu Server 22.04

Redis is an in-memory key-value store known for its flexibility, performance, and wide language support. This tutorial demonstrates how to install, configure, and secure Redis on an Ubuntu 22.04 server using EcoStack Cloud.

redis ubuntu database
Nano
VPS
1
vCPU
1 GB
Memory
10 GB
NVMe Disk
512 GB
Traffic
2.90
/month
* Up to 3GB RAM, 30GB NVMe Disk Space and 1Gbit/s Network Speed
## Binding to localhost By default, Redis is only accessible from localhost. However, if you installed and configured Redis by following a different tutorial than this one, you might have updated the configuration file to allow connections from anywhere. This is not as secure as binding to localhost. To correct this, open the Redis configuration file for editing: ```sh sudo nano /etc/redis/redis.conf ``` Locate this line and make sure it is uncommented (remove the `#` if it exists): ```plaintext /etc/redis/redis.conf . . . bind 127.0.0.1 ::1 . . . ``` Save and close the file when finished (press `CTRL + X`, `Y`, then `ENTER`). Then, restart the service to ensure that systemd reads your changes: ```sh sudo systemctl restart redis ``` To check that this change has gone into effect, run the following netstat command: ```sh sudo netstat -lnp | grep redis ``` ```plaintext tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 14222/redis-server tcp6 0 0 ::1:6379 :::* LISTEN 14222/redis-server ``` > **Note:** The `netstat` command may not be available on your system by default. If this is the case, you can install it (along with a number of other handy networking tools) with the following command: ```sh sudo apt install net-tools ``` This output shows that the `redis-server` program is bound to localhost (`127.0.0.1`), reflecting the change you just made to the configuration file. If there is another IP address in that column (`0.0.0.0`, for example), then you should double check that you uncommented the correct line and restart the Redis service again. Now that your Redis installation is only listening in on localhost, it will be more difficult for malicious actors to make requests or gain access to your server. However, Redis isn’t currently set to require users to authenticate themselves before making changes to its configuration or the data it holds. To remedy this, Redis allows you to require users to authenticate with a password before making changes via the Redis client (`redis-cli`). ---


Created with ❤ at Estonia
EcoStack Technology OÜ