In 2025–2026, installing and securing Redis on Ubuntu is a critical task for developers and sysadmins using Redis as a fast in-memory cache, session store, message broker, or real-time data engine. By default, Redis listens on all interfaces without authentication—leaving it vulnerable if port 6379 is exposed. This step-by-step guide shows you exactly how to install and secure Redis on Ubuntu (22.04 LTS, 24.04 LTS, and later), including binding to localhost, setting a strong password (or ACLs), renaming/disabling dangerous commands, and verifying everything works.

Follow these steps to get a production-ready, locked-down Redis instance quickly and safely.

Key Takeaways – How to Install and Secure Redis on Ubuntu

  • Install Redis on Ubuntu from official repositories with sudo apt install redis-server.
  • Set supervised systemd in redis.conf for proper service management and auto-restart.
  • Secure Redis on Ubuntu by binding to 127.0.0.1 ::1 (localhost only).
  • Add requirepass (or use Redis 6+ ACLs) for mandatory authentication.
  • Rename or disable risky commands (FLUSHALL, CONFIG, SHUTDOWN, etc.) to prevent data loss or reconfiguration attacks.
  • Test after every change with redis-cli ping, AUTH, SET/GET, and systemctl status redis.
  • Never expose Redis to the public internet—use SSH tunnels, VPN, or application proxy for remote access.

Prerequisites

  • Ubuntu server (22.04 LTS, 24.04 LTS, or later)
  • Non-root user with sudo privileges
  • Basic firewall (UFW recommended) already enabled
  • Follow the Initial Server Setup guide if not already done

Why You Must Secure Redis on Ubuntu

Redis has no built-in authentication or access control by default. If anyone can reach port 6379, they can:

  • Wipe all data with FLUSHALL
  • Reconfigure with CONFIG SET
  • Abuse persistence paths to write files (older versions)
  • Cause denial-of-service

Properly installing and securing Redis on Ubuntu eliminates these risks for local or trusted-network use cases.

Step 1: How to Install Redis on Ubuntu

Update packages and install Redis from Ubuntu’s official repositories:

				
					sudo apt update
sudo apt install redis-server
				
			

This gives you the latest stable Redis version with security patches via apt.

Enable systemd supervision (recommended):

				
					sudo nano /etc/redis/redis.conf
				
			

Find the supervised line (search with Ctrl+W) and change it to:

				
					supervised systemd
				
			

Save, exit, and restart:

				
					sudo systemctl restart redis.service
sudo systemctl enable redis
				
			

Verify it’s running:

				
					sudo systemctl status redis
				
			

Look for Active: active (running).

Step 2: Test Your Redis Installation on Ubuntu

Confirm Redis responds and persists data:

				
					redis-cli
				
			

Inside the prompt:

				
					127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set testkey "Hello Redis!"
OK
127.0.0.1:6379> get testkey
"Hello Redis!"
127.0.0.1:6379> exit
				
			

Restart and recheck:

				
					sudo systemctl restart redis
redis-cli get testkey
				
			

Should still return “Hello Redis!”.

Step 3: Bind Redis to Localhost (Critical Security Step)

Prevent remote connections by binding only to loopback.

Edit config:

				
					sudo nano /etc/redis/redis.conf
				
			

Ensure this line exists (uncommented):

				
					bind 127.0.0.1 ::1
				
			

Save, then restart:

				
					sudo systemctl restart redis
				
			

Verify binding:

				
					sudo ss -tlnp | grep 6379
				
			

You should see only 127.0.0.1:6379 and [::1]:6379 — not 0.0.0.0:6379.

Step 4: Add a Strong Password (Require Authentication)

Set requirepass (Redis 6+ also supports ACLs for advanced per-user control).

				
					sudo nano /etc/redis/redis.conf
				
			

Find or add under SECURITY section:

				
					requirepass your_very_strong_random_password_here
				
			

Generate a secure password:

				
					openssl rand -base64 48
				
			

Copy the output and paste it after requirepass (no quotes).

Restart Redis:

				
					sudo systemctl restart redis
				
			

Test authentication:

				
					redis-cli
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> AUTH your_very_strong_random_password_here
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> exit
				
			

Step 5: Rename or Disable Dangerous Commands

Protect against accidental or malicious use of risky commands.

Edit config:

				
					sudo nano /etc/redis/redis.conf
				
			

Add these lines under SECURITY (empty string disables; custom name renames):

				
					rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command CONFIG "CONFIG_RENAMED"
rename-command SHUTDOWN "SHUTDOWN_SAFE"
				
			

Restart:

				
					sudo systemctl restart redis
				
			

Test:

				
					redis-cli -a your_very_strong_random_password_here
AUTH your_very_strong_random_password_here
FLUSHALL
(error) ERR unknown command 'FLUSHALL'
				
			

Troubleshooting When Installing and Securing Redis on Ubuntu

  • Redis won’t start: Check logs sudo journalctl -u redis -n 50 — typos in redis.conf are common.
  • NOAUTH error: Forgot AUTH or wrong password.
  • Connection refused remotely: Expected—Redis is localhost-only. Use SSH tunnel or VPN.
  • Command renamed not working: Confirm lines are in active config and service restarted.

How to Install and Secure Redis on Ubuntu – FAQ (2025–2026)

  1. How do I install Redis on Ubuntu quickly?
    sudo apt update && sudo apt install redis-server — that’s how to install Redis on Ubuntu in one line.
  2. How do I secure Redis on Ubuntu by default? 
    Bind to localhost, set requirepass, and rename dangerous commands — the core steps to secure Redis on Ubuntu.
  3. What is the best way to install and secure Redis on Ubuntu 24.04? 
    Use the steps above: repositories install, supervised systemd, localhost bind, strong password, command renaming.
  4. How to install Redis on Ubuntu and add authentication? 
    After apt install, set requirepass yourpassword in redis.conf — essential when learning how to install and secure Redis on Ubuntu.
  5. How to install Redis on Ubuntu and prevent remote access? 
    Set bind 127.0.0.1 ::1 — this single line is critical to install and secure Redis on Ubuntu properly.
  6. Should I expose Redis to the internet after installing on Ubuntu? 
    Never. Always secure Redis on Ubuntu by keeping it localhost-only and using tunnels/VPN for remote access.

Summary

You’ve learned how to install and secure Redis on Ubuntu from scratch: install via apt, configure systemd supervision, bind to localhost, add strong authentication, and harden dangerous commands. Your Redis instance is now safe for caching, sessions, queues, and more.

Never expose port 6379 publicly. For managed Redis with replication, backups, and scaling, consider cloud options.

Recommended Resources

  • Official Redis Security Documentation
  • How to Set Up Redis with ACLs (Redis 6+)
  • How to Use Redis with Laravel / Django / Node.js
  • UFW Firewall Essentials on Ubuntu