Playbook
Install Redis
Redis, or Valkey where the distribution ships it, running and answering on this server only.
Category
Databases
Time limit per server
15 minutes
Temporary failures
Retried automatically, up to 2 times
Version
1.0
Supported systems
Ubuntu 22.04+, Debian 12+, RHEL-compatible 8+ (AlmaLinux, Rocky Linux, RHEL, CentOS Stream, Oracle Linux), Amazon Linux 2023+. Still runs on Ubuntu 20.04 and Debian 11, which are past the end of standard support.
When to use it
For caching, sessions and queues, for example in a Laravel application. The Laravel Server template can include it.
This playbook has no options.
What it does on the server
- Installs Redis from the distribution's packages:
redis-serveron Ubuntu and Debian,redison the RHEL family,redis6on Amazon Linux 2023. Where a RHEL-family release ships Valkey instead of Redis, it installs Valkey, which Redis clients can use unchanged. - Enables and starts the service, then checks that it answers a
PING. - Checks which addresses it listens on. The distributions' default configuration listens on this server only; if an existing installation accepts connections from the network, the run says so and leaves it unchanged.
After the run
Applications on the same server connect to 127.0.0.1:6379. Check it from the server with redis-cli ping (valkey-cli ping for Valkey, redis6-cli ping on Amazon Linux), which answers PONG.
Common problems
"… is running but did not answer a ping" — Redis started but refuses commands, usually because a password (requirepass) is set in its configuration file. Connect with that password, or check the requirepass line in the configuration (systemctl cat redis-server, redis or valkey shows which file the service reads).
"… accepts connections from the network" — Set bind 127.0.0.1 -::1 in its configuration and restart it, unless other servers need it. Never expose Redis to the internet without a password and a firewall rule.