How to Install and Configure Redis on Ubuntu 24.04
Learn how to install and configure redis on ubuntu 24.04 with systemd supervision, password security, persistence tuning, and UFW firewall rules.

5 min read
Learn how to install and configure redis on ubuntu 24.04 with systemd supervision, password security, persistence tuning, and UFW firewall rules.
- Prerequisites and Supported Releases
- Step 1: Installing Redis from Ubuntu Repositories
- Step 2: Configuring Systemd Supervision in /etc/redis/redis.conf
Modern web applications, real-time message brokers, and high-traffic APIs demand sub-millisecond data access speeds that traditional disk-based relational databases cannot achieve.
Redis (Remote Dictionary Server) is an open-source, in-memory data structure store used globally as a distributed cache, session manager, message broker, and fast database.
Supporting advanced data types including strings, hashes, lists, sets, sorted sets with range queries, and geospatial indexes, Redis combines blazing RAM speed with configurable disk persistence.
Deploying Redis securely on Ubuntu 24.04 LTS requires tuning process supervision, enforcing authentication, and restricting network exposure to prevent unauthenticated access.
In this guide, we walk through how to install and configure redis on ubuntu 24.04, verify functionality using redis-cli, configure persistence, and secure port 6379.
Complete step-by-step administrator and software engineer guide on deploying the Redis in-memory data store on Ubuntu 24.04 LTS (Noble Numbat). Explains installing the official redis-server package, configuring systemd supervision, enforcing strong password authentication with requirepass, tuning memory limits and snapshot persistence (RDB/AOF), and securing network bindings.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A server running Ubuntu 24.04 LTS or Ubuntu 22.04 LTS.
- A non-root user account with
sudoadministrative privileges. - UFW firewall installed and active.
- At least 512 MB of free RAM dedicated to caching.
Step 1: Installing Redis from Ubuntu Repositories
Ubuntu 24.04 includes the stable upstream release of Redis in the default universe package repository.
First, update your local APT repository index:
Install the redis-server package using apt:
Verify that the Redis service is active and starts automatically upon boot:
# Update repository cache and install Redis:
sudo apt update
sudo apt install -y redis-server
# Inspect Redis service status:
sudo systemctl status redis-server
# Expected output confirms:
# Active: active (running)
# Ensure service is enabled to launch on boot:
sudo systemctl enable redis-server
Step 2: Configuring Systemd Supervision in /etc/redis/redis.conf
The main configuration file for Redis resides at /etc/redis/redis.conf.
By default, the supervised directive is set to no, which prevents systemd from tracking the Redis daemon's lifecycle accurately.
To allow systemd to manage Redis properly, configure the supervised directive to systemd:
Open the configuration file in a text editor:
# Open Redis configuration:
sudo nano /etc/redis/redis.conf
# Locate the supervised directive and change from 'no' to 'systemd':
# supervised systemd
# Save and exit (Ctrl+O, Enter, Ctrl+X in nano).
# Restart the Redis service to apply supervision changes:
sudo systemctl restart redis-server
Step 3: Enforcing Strong Password Authentication (requirepass)
Redis can execute over 150,000 operations per second; an unauthenticated Redis instance exposed to the network can be compromised in seconds.
To secure your instance, configure a high-entropy password using the requirepass directive in /etc/redis/redis.conf.
Generate a 64-character cryptographic password string using openssl:
Set the generated password inside the configuration file:
# Generate a strong random password hash:
openssl rand 60 | openssl base64 -A
# Example output: vG7z...K9x2
# In /etc/redis/redis.conf, locate requirepass and add your secret:
# requirepass YOUR_STRONG_GENERATED_PASSWORD
# Restart Redis daemon:
sudo systemctl restart redis-server
Testing Password Authentication with redis-cli
Launch the interactive Redis command-line interface and verify that unauthenticated commands are rejected:
Authenticate using the AUTH command and test data operations:
# Launch redis-cli:
redis-cli
# 1. Attempt unauthenticated command (fails):
127.0.0.1:6379> ping
# Error: (error) NOAUTH Authentication required.
# 2. Authenticate with your password:
127.0.0.1:6379> AUTH YOUR_STRONG_GENERATED_PASSWORD
# Output: OK
# 3. Test data insertion and retrieval:
127.0.0.1:6379> set framework "Next.js"
# Output: OK
127.0.0.1:6379> get framework
# Output: "Next.js"
127.0.0.1:6379> exit
Step 4: Configuring Memory Limits and Eviction Policies
If Redis consumes all available system RAM, the Linux kernel's Out-Of-Memory (OOM) killer will abruptly terminate processes.
Configure a maximum memory cap using maxmemory and define an intelligent cache eviction policy using maxmemory-policy:
Open /etc/redis/redis.conf and add these memory parameters:
# In /etc/redis/redis.conf, configure memory boundaries:
# maxmemory 512mb
# maxmemory-policy allkeys-lru
# The allkeys-lru policy automatically removes the least recently used keys
# when the 512 MB memory threshold is reached.
Enabling Append Only File (AOF) Persistence
By default, Redis snapshots data to disk using RDB at scheduled intervals (such as every 15 minutes if 1 key changes).
For mission-critical production workloads that require zero data loss, enable Append Only File (AOF) persistence.
AOF logs every write operation received by the server, syncing to disk every second:
Enable AOF in /etc/redis/redis.conf and restart Redis:
# In /etc/redis/redis.conf, enable AOF:
# appendonly yes
# appendfsync everysec
# Restart Redis daemon to initialize AOF logging:
sudo systemctl restart redis-server
Step 5: Securing Network Bindings and UFW Firewall Rules
Verify that Redis is bound exclusively to the local loopback adapter (bind 127.0.0.1 ::1) in /etc/redis/redis.conf.
If you are deploying Redis on a dedicated database server accessed by remote application servers across a private VPC, bind to the private network interface (e.g. 192.168.1.100):
Never expose Redis port 6379 to the public internet; restrict UFW firewall access strictly to your application server IP:
# Verify Redis is listening strictly on localhost:
sudo ss -tulpn | grep 6379
# Output confirms: 127.0.0.1:6379
# If operating across a private VPC, allow port 6379 ONLY from your web server:
sudo ufw allow from 192.168.1.50 to any port 6379 proto tcp comment 'Redis from Web App'
# Verify active UFW rules:
sudo ufw status
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
NOAUTH Authentication required error when application connects
Cause: Application did not supply the password configured in requirepass.
Resolution: Update your application environment variables (.env) with the Redis password string.
redis-cli -a YOUR_PASSWORD ping
OOM command not allowed when used memory > 'maxmemory'
Cause: Redis reached the maxmemory threshold and the eviction policy is set to noeviction.
Resolution: Change maxmemory-policy to allkeys-lru or increase the maxmemory allocation in /etc/redis/redis.conf.
sudo sed -i 's/^maxmemory-policy .*/maxmemory-policy allkeys-lru/' /etc/redis/redis.conf && sudo systemctl restart redis-server
WARNING: Memory overcommit must be enabled in the kernel
Cause: Linux kernel vm.overcommit_memory parameter is set to 0, which can cause Redis background saves to fail.
Resolution: Add vm.overcommit_memory = 1 to /etc/sysctl.conf and apply with sudo sysctl -p.
sudo sysctl vm.overcommit_memory=1
Security Best Practices and Hardening
Never bind Redis to 0.0.0.0 without strict firewall rules and password protection; open Redis instances are targeted by ransomware bots.
Consider renaming dangerous commands (such as FLUSHALL, FLUSHDB, CONFIG) using rename-command FLUSHALL "" in /etc/redis/redis.conf.
Keep Redis updated with security patches via standard sudo apt update && sudo apt upgrade.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
- How to Set Up a Firewall with UFW on Ubuntu 24.04 — Configure UFW rules to restrict Redis port 6379 to trusted application nodes.
- How to Install and Configure Memcached on Ubuntu 24.04 — Compare Redis features with simple in-memory Memcached key-value caching.
- Initial Server Setup on Ubuntu 24.04 LTS — Harden Linux server configuration before deploying database infrastructure.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
6379 by default. The port number corresponds to 'MERZ' on a traditional telephone keypad, named after Italian showgirl Alessia Merz by Redis creator Salvatore Sanfilippo.redis-cli -a YOUR_PASSWORD info memory. This returns detailed memory metrics, including used_memory_human, used_memory_peak_human, and fragmentation ratios.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides
Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!