redis-cli: Usage, Options & Common CI Errors
redis-cli sends commands to a Redis server from the shell.
redis-cli is how pipelines seed cache state and assert keys against a Redis service container. The standout CI errors are NOAUTH on a password-protected server and connecting before it is ready.
What it does
redis-cli connects to a Redis server and runs commands interactively or as a single command line. In CI it points at a service container to set keys, flush state, or check liveness with PING.
Common usage
redis-cli -h 127.0.0.1 -p 6379 PING
redis-cli -h 127.0.0.1 -p 6379 -a secret SET k v # password
REDISCLI_AUTH=secret redis-cli -h 127.0.0.1 SET k v # password via env
redis-cli -h 127.0.0.1 -n 2 GET k # database index 2
until redis-cli -h 127.0.0.1 ping | grep -q PONG; do sleep 1; doneOptions
| Flag | What it does |
|---|---|
| -h <host> / -p <port> | Server host / port (default 6379) |
| -a <password> | Password (or REDISCLI_AUTH env var) |
| --user <name> | ACL username (Redis 6+) |
| -n <db> | Select database index (0-15) |
| --scan | Iterate keys without blocking (vs KEYS) |
| -r <N> -i <secs> | Repeat a command N times every interval |
Common errors in CI
NOAUTH Authentication required. - the server has requirepass set; pass -a (or REDISCLI_AUTH to avoid the "Using a password on the command line ... insecure" warning). "WRONGPASS invalid username-password pair" is a wrong password/ACL user. "Could not connect to Redis at 127.0.0.1:6379: Connection refused" means the server is not up yet - loop on PING. Note -a SECRET on the CLI leaks into process lists; REDISCLI_AUTH is the cleaner CI form.