Redis::CannotConnectError: Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)
Sidekiq or the Rails Redis cache/cable couldn't connect to Redis.
Redis::CannotConnectError: Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)Redis::CannotConnectError: Error connecting to Redis on redis:6379 (SocketError) Meaning
Start Redis, set REDIS_URL for Sidekiq (Sidekiq.configure_server/client { |c| c.redis = { url: ENV["REDIS_URL"] } }), and use the service name in Docker. For TLS endpoints (Heroku Redis, ElastiCache) pass ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE } only if required by the provider; prefer proper certs.
Common causes
- Redis not running
REDIS_URLunset/wrong- Docker using localhost
- TLS-required managed Redis (rediss://)
- Network/firewall
⚡ Quick fix
- Start Redis:
redis-server/brew services start redis - Set
REDIS_URLfor server and client - Use
rediss://and SSL params for managed TLS Redis
Detailed fix by platform
Rails
redis-cli -u $REDIS_URL ping
How to diagnose
- Server — Running?
- URL — REDIS_URL?
- TLS — rediss?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- ActiveRecord::AssociationTypeMismatch Rails: ActiveRecord::AssociationTypeMismatch: User(#1234) expected, got "42" which is an instance of String(#5678)
- ActiveRecord::ConnectionNotEstablished Rails: ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found
- ActiveRecord::Deadlocked: PG::TRDeadlockDetected Rails: ActiveRecord::Deadlocked: PG::TRDeadlockDetected: ERROR: deadlock detected
Most viewed in Ruby / Rails
- ActiveRecord::PendingMigrationError Rails: ActiveRecord::PendingMigrationError — Migrations are pending. To resolve this issue, run: bin/rails db:migrate
- undefined method for nil Ruby: NoMethodError: undefined method `x' for nil (nil:NilClass)
- ActionController::InvalidAuthenticityToken Rails: ActionController::InvalidAuthenticityToken (Can't verify CSRF token authenticity)
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026