Install and Secure Redis on Ubuntu 22.04 for reliable cache and data protection. Our Redis Support team is ready to assist you.
How to Install and Secure Redis on Ubuntu 22.04
Redis is a powerful in-memory data store used for caching, database management, and message brokering. To ensure both performance and security, follow these six steps to install and secure Redis on Ubuntu 22.04.

Prerequisites
Before installing Redis on Ubuntu 22.04, ensure you have the following:
- An updated Ubuntu 22.04 system
- A stable internet connection
- A user account with sudo privileges
- Access to the terminal
You may also want to research Redis cache alternatives if you plan on scaling your caching strategy or exploring different options.
Once these are ready, you can smoothly install and secure Redis on your server.
Step 1: Install Redis on Ubuntu
Update the system and install Redis from Ubuntu’s official repositories:
sudo apt update
sudo apt install redis-serverOnce installed, Redis runs automatically. You can verify this later, but first, configure it for better process management.
Deploy and protect Redis on Ubuntu easily.

Step 2: Configure Redis for systemd
Open the Redis configuration file:
sudo nano /etc/redis/redis.confFind the line that begins with supervised and change its value to systemd:
supervised systemdSave and close the file, then restart Redis:
sudo systemctl restart redis.serviceThis enables Redis to work smoothly with Ubuntu’s init system.
Step 3: Verify Redis Installation
Check that Redis is running correctly:
sudo systemctl status redisIf active, connect to the Redis command-line tool:
redis-cliTest connectivity:
pingOutput:
PONGThen try setting and retrieving a key:
set test “It’s working!”
get test
You can also explore Redis bloom filter commands at this stage to enhance memory-efficient probabilistic data operations.
If you receive the same output, Redis is working as expected.
Step 4: Bind Redis to Localhost
To enhance security, make sure Redis only listens to local connections. Open the configuration file again:
sudo nano /etc/redis/redis.confEnsure this line is present and uncommented:
bind 127.0.0.1 ::1Save, close, and restart Redis:
sudo systemctl restart redisCheck the binding:
sudo netstat -lnp | grep redisIt should show Redis bound only to 127.0.0.1.
Step 5: Set a Strong Redis Password
Set up password authentication by editing the same configuration file:
sudo nano /etc/redis/redis.confUncomment and update the requirepass directive with a strong password:
requirepass your_secure_passwordGenerate a random password using:
openssl rand 60 | openssl base64 -ARestart Redis:
sudo systemctl restart redis.serviceTest authentication:
redis-cli
set key1 10Output:
(error) NOAUTH Authentication required.Authenticate and retry:
auth your_secure_password
set key1 10
get key1Redis now requires a password before allowing access.
Step 6: Rename or Disable Dangerous Commands
For extra security, disable or rename risky commands that can affect your data. Open the configuration file:
sudo nano /etc/redis/redis.confUnder the SECURITY section, add:
rename-command FLUSHDB ""
rename-command FLUSHALL ""
rename-command CONFIG ASC12_CONFIG
rename-command SHUTDOWN SHUTDOWN_MENOTSave the file and restart Redis:
sudo systemctl restart redis.serviceThis ensures unauthorized users cannot execute destructive commands.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
By following these steps to install and secure Redis on Ubuntu 22.04, you’ve created a fast, reliable, and secure setup ready to power your applications efficiently.
