Redis::CannotConnectError in CI
The Redis client could not establish a connection. The Redis service may not be up yet, or REDIS_URL points at the wrong host/port. Connecting to a starting cache/queue service is a common transient failure.
What this error means
Tests or boot fail with Redis::CannotConnectError (connection refused or timeout). Often intermittent while the Redis service container is still starting.
Redis::CannotConnectError: Error connecting to Redis on
localhost:6379 (Errno::ECONNREFUSED)Common causes
Service not ready
The app connected before the Redis service container began accepting connections.
Wrong URL/host/port
REDIS_URL or the configured host/port does not match the CI Redis service.
Redis not provisioned
The workflow never started a Redis service, but the test setup (Sidekiq, cache, ActionCable) needs one.
How to fix it
Provision Redis and wait for it
Start a Redis service, point REDIS_URL at it, and gate on readiness.
until redis-cli -h localhost -p 6379 ping | grep -q PONG; do sleep 1; done
# REDIS_URL: redis://localhost:6379/0Configure the client from env
- Set REDIS_URL in the job env to the service address.
- Add a redis service (or container) to the workflow.
- Gate the test step on a successful PING.
How to prevent it
- Add a Redis readiness gate before tests.
- Drive Redis config from REDIS_URL matching the service.
- On self-healing managed runners (Latchkey), transient Redis connection failures during service startup are auto-retried rather than failing the job.