Redis::CannotConnectError (Sidekiq/Rails) Ruby / Rails Origin: Application & API Last updated 5 Nov 2026

Redis::CannotConnectError: Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)

Sidekiq or the Rails Redis cache/cable couldn't connect to Redis.

Exact message you may see 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)
Seen on: Ruby Redis

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_URL unset/wrong
  • Docker using localhost
  • TLS-required managed Redis (rediss://)
  • Network/firewall

⚡ Quick fix

  1. Start Redis: redis-server / brew services start redis
  2. Set REDIS_URL for server and client
  3. Use rediss:// and SSL params for managed TLS Redis

Detailed fix by platform

Rails

  1. redis-cli -u $REDIS_URL ping

How to diagnose

  1. Server — Running?
  2. URL — REDIS_URL?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

ActiveRecord::AssociationTypeMismatch — Rails: ActiveRecord::AssociationTypeMismatch: User(#1234) expected, got "42" which is an instance of String(#5678) (Ruby / Rails)ActiveRecord::Associa…ActiveRecord::ConnectionNotEstablished — Rails: ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found (Ruby / Rails)ActiveRecord::Connect…ActiveRecord::Deadlocked: PG::TRDeadlockDetected — Rails: ActiveRecord::Deadlocked: PG::TRDeadlockDetected: ERROR: deadlock detected (Ruby / Rails)ActiveRecord::Deadloc…ActiveRecord::IrreversibleMigration — Rails: ActiveRecord::IrreversibleMigration — This migration uses remove_column without a type; db:rollback can't reverse it (Ruby / Rails)ActiveRecord::Irrever…Bad file format reading the append only file / AOF corrupted — Redis: Bad file format reading the append only file: make a backup of your AOF file, then use ./redis-check-aof --fix <filename> (Redis)Bad file format readi…BullMQ: Missing lock for job / job stalled more than allowable limit — BullMQ: Error: Missing lock for job 42. moveToFinished / job stalled more than allowable limit (Redis)BullMQ: Missing lock …BUSY Redis is busy running a script — Redis: (error) BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE (Redis)BUSY Redis is busy ru…Can't connect to Redis from another host (bind 127.0.0.1) — Redis: Could not connect to Redis at 10.0.0.5:6379: Connection timed out (Redis)Can't connect to Redi…Redis::Ca…

Explore the map of this error Full error map →

🧠 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.