Skip to main content
To install Redis on Ubuntu or Debian, run sudo apt update and sudo apt install redis-server. The service starts by itself and listens only on 127.0.0.1 port 6379. Test it with redis-cli ping, which answers PONG. Then set a password and a memory limit in /etc/redis/redis.conf and restart with sudo systemctl restart redis-server.

Before you start

  • You need a user with sudo rights. If you are logged in as root, leave out sudo.
  • Redis is an in-memory data store: it keeps data in RAM, so it is very fast. Apps use it as a cache, for sessions or for job queues (for example WordPress object caching, Laravel or Discord bots).
  • Plan how much RAM Redis may use. See check memory usage.

How to install Redis

1

Install the package

Ubuntu 24.04 installs Redis 7.0.
2

Check the service

Look for active (running). Press q to leave.
For the newest Redis release, use the official Redis APT repository:

How to check Redis works

Store and read a test value:
The second command prints "hello".

How to secure Redis

The Redis security guide warns that it is “not a good idea to expose the Redis instance directly to the internet”. On Ubuntu and Debian the config already has safe defaults:
bind keeps Redis on the server itself. Protected mode makes Redis refuse outside clients when it has no password. Leave both as they are.
Do not change bind to 0.0.0.0 or set protected-mode no on a public server. An open Redis lets anyone read or delete all your data with one command. If another server needs Redis, connect over a private VPN such as WireGuard and allow only that address in your firewall.

How to set a Redis password

1

Edit the config

Find the commented line # requirepass foobared and add below it:
Use a long random password. Redis answers so fast that short passwords can be guessed quickly.
2

Restart Redis

On AlmaLinux / Rocky 9 the service is redis.
3

Test it

You now get NOAUTH Authentication required. Log in with redis-cli --askpass, type the password, then run ping again.
requirepass is the simple, legacy method that gives one password to every client. Redis 6 and later also support named users with their own rights through ACLs (access control lists), which Redis recommends for larger setups.

How to limit Redis memory

Without a limit, Redis keeps growing until the server runs out of RAM. In /etc/redis/redis.conf, set:
allkeys-lru removes the least recently used keys when the limit is reached, which suits a cache. Keep the default noeviction if Redis stores data you must not lose, such as queues. Restart Redis after the change.

Frequently asked questions

Where are Redis logs and data stored on Ubuntu?

The log is /var/log/redis/redis-server.log and data files are saved in /var/lib/redis.

Is Redis data lost on restart?

Not by default, but you can lose changes made since the last snapshot. Redis 7.0 saves a snapshot after 3600 seconds if at least 1 key changed, after 300 seconds if 100 changed, or after 60 seconds if 10,000 changed. Set appendonly yes to log every write for stronger durability.

How do I connect PHP to Redis?

Install the PHP extension, for example sudo apt install php-redis, then restart PHP-FPM. Point your app at 127.0.0.1 port 6379 with your password.

Can I run Redis in Docker instead?

Yes. See install Docker and use Docker Compose. Do not publish port 6379 to the internet.

VPS and dedicated server guides

Every guide in this section.

Install PostgreSQL

A database to pair with Redis.

Install WordPress on a VPS

Use Redis for object caching.

Host a Discord bot

Bots often keep state in Redis.

Check open ports

Confirm 6379 is not public.

Checked against the official Redis documentation and Redis security guide on 4 November 2026; install, redis-cli, password and memory settings tested on Ubuntu 24.04 LTS with Redis 7.0. Commands can differ on other distributions or releases.

Need Extra Help?

If you encounter any issues, our support team is ready to assist:

Save on Your Hosting

Ready to upgrade your hosting? Use code KB20 at checkout for 20% off your first order!

Last Updated: November 2026