Skip to content
Latchkey

redis-cli Command Reference: Flags, Usage & CI Examples

redis-cli is the command-line client for a Redis server.

redis-cli connects to a Redis server and runs commands interactively or as one-shot arguments. In CI it seeds keys, flushes state, and provides a readiness healthcheck.

Common flags and usage

  • -h <host> / -p <port>: server host and port (default 6379)
  • -a <password>: authenticate (or set REDISCLI_AUTH)
  • -n <db>: select a logical database number
  • ping: returns PONG when the server is up
  • -u redis://...: connect with a single URI
  • --scan: iterate keys without blocking like KEYS

Example

shell
until [ "$(redis-cli -h localhost -p 6379 ping)" = "PONG" ]; do
  echo "waiting for redis..."; sleep 1
done
redis-cli -u "${REDIS_URL}" set warmed 1

In CI

redis-cli ping is the standard healthcheck: loop until it returns PONG before tests connect. Pass auth via REDISCLI_AUTH rather than -a on the command line to keep the password out of the process list.

Key takeaways

  • redis-cli runs Redis commands as one-shot args or interactively.
  • A ping that returns PONG is the canonical readiness healthcheck.
  • Prefer REDISCLI_AUTH over -a to hide the password from ps.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →