redis-cli ping: Usage, Options & Common CI Errors
redis-cli PING returns PONG when a Redis server is alive and reachable.
PING is the canonical Redis readiness probe in CI. The subtlety is that on a password-protected server PING itself returns NOAUTH, so the wait loop must authenticate first.
What it does
The PING command asks the Redis server to reply PONG, confirming the connection is open and the server is processing commands. It is the standard liveness check before a pipeline writes or reads keys.
Common usage
redis-cli -h 127.0.0.1 ping # -> PONG
redis-cli -h 127.0.0.1 -a secret ping # auth then ping
until [ "$(redis-cli -h 127.0.0.1 ping)" = "PONG" ]; do sleep 1; done
redis-cli -h 127.0.0.1 ping hello # -> hello (echo argument)Options
| Item | What it does |
|---|---|
| ping | Returns PONG if the server is up |
| ping <message> | Echoes the message instead of PONG |
| -a <password> | Authenticate before PING (avoids NOAUTH) |
| -h <host> / -p <port> | Target the service container |
Common errors in CI
On a server with requirepass, a bare ping returns NOAUTH Authentication required. rather than PONG, so an unauthenticated wait loop never sees PONG and hangs - include -a/REDISCLI_AUTH. "Connection refused" while the container starts is expected; the loop should keep retrying. A wait loop that checks exit status is fragile because redis-cli often exits 0 even on NOAUTH; compare the literal output to PONG instead.