How to install Redis on Ubuntu 24
To install Redis on Ubuntu you can use the package in Ubuntu’s own repository, Redis 7.0 on 24.04 and 6.0 on 22.04, or the newest release from the official Redis repository. Redis trusts every client that reaches it, so it should never sit open to the internet. This guide shows how systemd runs it, how to add a password or an ACL user and how to let a second server in without exposing it.
Install Redis on Ubuntu with apt
The redis-server package installs the server and redis-cli, and starts the service right away.
sudo apt update
sudo apt install -y redis-server
redis-server --version
redis-cli pingThe ping answers PONG when the server works. The settings are in /etc/redis/redis.conf, the data in /var/lib/redis/ and the log in /var/log/redis/redis-server.log.
Check that systemd supervises Redis
Older guides tell you to change supervised no to supervised systemd in redis.conf. With Ubuntu’s package you don’t need to: its service already starts Redis with --supervised systemd --daemonize no, and these options win over the file. You can see it for yourself:
systemctl status redis-server --no-pager
systemctl cat redis-serverThe status shows Active: active (running), and the unit has a line ExecStart=/usr/bin/redis-server /etc/redis/redis.conf --supervised systemd --daemonize no. The service is enabled, so Redis comes back after a reboot. Apply changes to redis.conf with:
sudo systemctl restart redis-serverSet a password: requirepass or an ACL user
Out of the box any program on the server can connect without a password. The simple fix is requirepass: one password for every client. Make it long and random, for example with this command:
openssl rand -hex 32Find the commented # requirepass foobared line in the settings file and put your own password in its place:
requirepass choose-a-long-random-passwordsudo systemctl restart redis-server
redis-cli --askpass pingredis-cli asks for the password and answers PONG. Without it, commands return NOAUTH Authentication required. Since Redis 6 you can also give each app its own user with its own rights (ACL). This line in the same file creates user app that can use all keys but not dangerous commands such as FLUSHALL or CONFIG:
user app on >choose-another-long-password ~* &* +@all -@dangerousAfter a restart, connect as that user:
redis-cli --user app --askpassThe app then signs in with both the user name and the password.
Let another server connect, carefully
Ubuntu’s Redis listens only on 127.0.0.1 and ::1. That is right when the app runs on the same server. If it runs on another one, use a private network between them, never the public internet: Redis traffic, including the password, isn’t encrypted. This command shows this server’s private address:
ip -4 addrAdd that address to the bind line:
bind 127.0.0.1 -::1 10.0.0.5Set a password first, as above, then restart Redis and open port 6379 for the app server alone. Replace 10.0.0.6 with its address.
sudo systemctl restart redis-server
sudo ufw allow from 10.0.0.6 to any port 6379 proto tcpLeave protected-mode yes as it is. A UFW rule protects only while UFW is on, so check it with: sudo ufw status Before turning UFW on over SSH, allow SSH with: sudo ufw allow OpenSSH
Install the latest Redis from packages.redis.io
Ubuntu keeps one Redis version for the life of each release. The Redis project has its own apt repository with current releases. These commands from its install page add the signing key and the repository, then install Redis from there.
sudo apt-get install lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg
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
sudo apt-get update
sudo apt-get install redisThe service keeps the name redis-server and starts by itself. If it doesn’t, run:
sudo systemctl enable redis-server
sudo systemctl start redis-serverCheck the version and the settings file the service reads:
redis-server --version
systemctl cat redis-serverInstalled over Ubuntu’s Redis, apt asks whether to keep your /etc/redis/redis.conf. If you keep it, the new service fails with Failed with result 'protocol': the new unit doesn’t pass --supervised systemd any more. Set these two lines in the file and restart Redis:
daemonize no
supervised systemdsudo systemctl restart redis-serverIf Redis doesn’t start or answer
Could not connect to Redis at 127.0.0.1:6379: Connection refused: the server isn’t running. A typo inredis.confis the usual cause. See why in the service journal:sudo journalctl -u redis-server -n 50The Redis log shows it too:sudo tail -n 50 /var/log/redis/redis-server.logNOAUTH Authentication required.: a password is set. SendAUTHwith the password first, or connect with:redis-cli --askpassWRONGPASS invalid username-password pair or user is disabled.: the password is wrong, or the ACL user lackson.DENIED Redis is running in protected mode: a client from another machine reached Redis with no password set. Set a password and abindaddress as above, and don’t turn protected mode off.WARNING Memory overcommit must be enabled!in the log: background saving may fail when memory runs low. The Redis docs say to addvm.overcommit_memory = 1to/etc/sysctl.confand apply it now with:sudo sysctl vm.overcommit_memory=1
If you also work on a Mac

System Junk in MacWashing finds the caches of every app it knows, including those hidden inside app data, plus logs, Xcode junk and leftovers of deleted apps. It shows how much each takes and clears them in one go. Anything debatable stays unchecked until you decide.
Free trial · macOS 14 or later
Questions and answers
How do I install Redis on Ubuntu?
Install the redis-server package with apt and check that the server answers PONG, as the first section shows. Ubuntu 24.04 installs Redis 7.0 and 22.04 installs 6.0.
Is Redis safe to open to the internet?
No. The Redis docs say it is meant for trusted clients in a trusted network. Keep it on 127.0.0.1 or a private network, with a password and a firewall rule for each app server.
Where does Redis keep its data?
In /var/lib/redis/, as the dump.rdb snapshot by default. Redis keeps everything in memory and saves the snapshot from time to time, as set by the save lines in redis.conf.