How to install Redis on Ubuntu 24.04 and secure it
To install Redis on Ubuntu 24.04, add the official packages.redis.io APT repository, run sudo apt-get install redis, then set a password, a memory limit and persistence in /etc/redis/redis.conf. Keep Redis bound to 127.0.0.1; on a server with a public address, reach it from your laptop through an SSH tunnel. This guide installs Redis Open Source 8.10.3, the latest stable release as of Nov 20, 2026, and also covers a Docker setup, updates and backups. It takes about 10 minutes.
Want your AI agent to do it? Paste this prompt into Claude Code, Cursor or ChatGPT with the 0x.cloud MCP server connected:
Create an s1-2 server with Ubuntu 24.04 on 0x.cloud. Show the dry_run price and wait for my "yes". Then, with run_command, install Redis from the official packages.redis.io repository, keep bind 127.0.0.1 -::1, set a random requirepass, maxmemory 512mb with allkeys-lru, enable appendonly, set vm.overcommit_memory=1, then send me the password.
Requirements and server size
Redis is an in-memory store, so RAM is what you size for:
| Workload | Plan | Memory for Redis |
|---|---|---|
| Cache, sessions or a queue for one bot or site | s1-1: 1 vCPU, 1 GB, $4.49/mo | up to 256 MB |
| Redis next to your app and database | s1-2: 1 vCPU, 2 GB, $7.99/mo | 512 MB to 1 GB |
| Several projects, BullMQ or Celery queues, JSON search | s2-4: 2 vCPU, 4 GB, $15.99/mo | 1.5 to 2.5 GB |
Our pick: s1-2 at $7.99/mo, about $0.054725 an hour. An empty Redis uses 10–20 MB; the rest is your data. With 2 GB you can give Redis 512 MB and still leave room for your app and the OS. All plans are on the VPS pricing page.
Ubuntu 24.04 LTS or Debian 12 both work. Disk usage roughly matches the dataset size, since dump.rdb and the AOF files mirror what's in memory. If your app also needs a relational database, see install PostgreSQL on Ubuntu 24.04.
Setup costs $0. On hourly billing, delete it after a test and the unused balance goes back to your account.
Prepare the server
Open the web console of the server in your cabinet (an agent runs the same commands with run_command), update packages and enable the firewall:
sudo apt update && sudo apt upgrade -y
sudo ufw allow OpenSSH
sudo ufw enable
Don't add a rule for 6379. Redis will listen on localhost only. More on rules in UFW firewall on Ubuntu.
Install Redis on Ubuntu from the official repository
Ubuntu 24.04's archive carries Redis 7.0.15. For Redis 8, use the repository maintained by Redis:
sudo apt-get install -y 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 -y redis
The first commands import the signing key and add the repo for your release (noble on Ubuntu 24.04, resolute on 26.04, bookworm on Debian 12; the repo covers all three). The last one installs redis-server plus redis-tools. The service starts right away and is enabled at boot; if it isn't, run sudo systemctl enable --now redis-server. Confirm:
redis-cli ping
redis-server --version
PONG means it works. Redis 8 bundles JSON, the query engine (full-text and vector search), time series and probabilistic types in the core server, so you no longer need Redis Stack.
A note on licensing. Starting with version 8, Redis Open Source is offered under your choice of RSALv2, SSPLv1 or AGPLv3 (terms on redis.io). Running it for your own app on your own server is free; the restrictions target companies selling Redis to others as a managed service. Ubuntu's Redis 7.0.15 is still BSD-licensed, and if you want BSD for current releases, the Valkey fork is the option.
Configure password, network and memory
Open the config:
sudo nano /etc/redis/redis.conf
Find and set these lines (Ctrl+W searches in nano):
bind 127.0.0.1 -::1
protected-mode yes
requirepass REPLACE_WITH_A_LONG_PASSWORD
maxmemory 512mb
maxmemory-policy allkeys-lru
appendonly yes
appendfsync everysec
bind 127.0.0.1 -::1keeps Redis on the loopback interface, so local apps connect and the internet can't;requirepasssets the password for the default user. Generate one withopenssl rand -hex 32;maxmemorycaps memory andallkeys-lruevicts the least recently used keys when the cap is hit. For job queues (BullMQ, Celery, Sidekiq) usenoevictioninstead, or jobs will silently disappear;appendonly yeslogs every write, so a crash loses at most about one second of data.
Redis also warns when the kernel doesn't allow memory overcommit, which can make background saves fail. Fix it once:
echo "vm.overcommit_memory = 1" | sudo tee /etc/sysctl.d/90-redis.conf
sudo sysctl --system
sudo systemctl restart redis-server
Test the password. --askpass prompts for it, so it doesn't land in your shell history:
redis-cli --askpass
127.0.0.1:6379> PING
127.0.0.1:6379> INFO memory
Apps on the same server connect with redis://:PASSWORD@127.0.0.1:6379/0.
Reach Redis remotely through an SSH tunnel
Incoming connections from the internet don't reach 0x.cloud servers, so this is for a server with a public address. To use RedisInsight or redis-cli on your laptop, forward the port over SSH:
ssh -N -L 6379:127.0.0.1:6379 user@SERVER_IP
While it runs, Redis answers on your localhost:6379. Exposing 6379 to the internet, even with a password, invites constant scanning and brute force, so the tunnel is the safer default.
Alternative: install Redis with Docker
If Redis belongs to one project, keep it in that project's compose.yaml. Install Docker first with how to install Docker on Ubuntu 24.04, then:
services:
redis:
image: redis:8.10
restart: unless-stopped
command: ["redis-server", "--requirepass", "${REDIS_PASSWORD}", "--appendonly", "yes", "--maxmemory", "512mb"]
ports:
- "127.0.0.1:6379:6379"
volumes:
- redis_data:/data
volumes:
redis_data:
Put REDIS_PASSWORD=… in a .env file next to it. The 127.0.0.1: prefix matters: Docker writes its own iptables rules and bypasses ufw, so a bare 6379:6379 would expose Redis publicly. If your app runs in the same compose file, drop ports entirely and connect to redis:6379.
Start on boot
The package enables the service for you. Check:
sudo systemctl is-enabled redis-server
sudo systemctl status redis-server
Read logs with sudo journalctl -u redis-server. The Docker variant restarts after a reboot thanks to restart: unless-stopped.
Update Redis
sudo apt-get update
sudo apt-get install --only-upgrade redis redis-server redis-tools
sudo systemctl restart redis-server
Read the release notes before moving to a new minor line, for example 8.10 to 8.12, and take a backup first. The official docs show how to pin a release line with a file in /etc/apt/preferences.d/. With Docker, change the image tag and run docker compose pull && docker compose up -d.
Back up Redis
redis-cli --rdb pulls a fresh snapshot from the running server with no downtime:
mkdir -p ~/redis-backup
REDISCLI_AUTH='YOUR_PASSWORD' redis-cli --rdb ~/redis-backup/dump-$(date +%F).rdb
To restore: stop Redis, rename /var/lib/redis/appendonlydir, copy the file to /var/lib/redis/dump.rdb (owner redis:redis) and temporarily set appendonly no. Start the service, run CONFIG SET appendonly yes in redis-cli so Redis builds a new AOF from the loaded data, then set appendonly yes back in the config. Store copies off the server. On 0x.cloud you can also turn on automatic whole-server backups (7 daily copies, +20% of the plan price); see VPS backups for how they compare with snapshots.
Common errors
| Symptom | Cause and fix |
|---|---|
NOAUTH Authentication required |
A password is set. Use --askpass or put the password in your app's connection URL |
Could not connect to Redis at 127.0.0.1:6379: Connection refused |
Service is down or the config has a typo. Check journalctl -u redis-server |
WARNING Memory overcommit must be enabled! |
Set vm.overcommit_memory = 1 as shown above |
OOM command not allowed when used memory > 'maxmemory' |
noeviction policy and memory is full. Raise maxmemory or move to a bigger plan |
MISCONF Redis is configured to save RDB snapshots |
Redis can't write to disk: full disk or wrong owner on /var/lib/redis |
DENIED Redis is running in protected mode |
Remote connection without a password. Connect from the server itself or through an SSH tunnel |
Official guide: Install Redis Open Source on Linux.
FAQ
Which Redis version does apt install on Ubuntu 24.04? Ubuntu's own repository ships Redis 7.0.15. The official packages.redis.io repository gives you the current 8.x line (8.10.3 as of Nov 20, 2026) with JSON, search and time series built in.
How do I connect to Redis on my server from my laptop? Keep port 6379 closed and use an SSH tunnel: ssh -N -L 6379:127.0.0.1:6379 user@SERVER_IP. Your laptop then talks to localhost:6379, and the traffic travels inside SSH. This needs a server reachable from the internet: incoming connections don't reach 0x.cloud servers.
How much RAM does Redis need? Redis keeps the whole dataset in memory. A cache or job queue for a small app fits in 256–512 MB, so a 2 GB server (s1-2) is a comfortable start. Always set maxmemory so Redis can't starve your app.
What if I misconfigure Redis or the server isn't a fit? Test on hourly billing: s1-2 costs about $0.054725 an hour. Take a $0.99/mo snapshot before experiments, and if you break the config, reinstall the OS for $0. Delete the server and charges stop at once, with the unused balance returned. Servers are in Warsaw, and support answers in about 30 minutes, 06:00–20:00 UTC.
Should I install Redis with apt or Docker? Use apt for one shared Redis managed by systemd and updated with the OS. Use Docker when Redis belongs to a single project's compose file. Either way, publish the port on 127.0.0.1 only.