redis attempting to connect to local host in Heroku - WHY? redis attempting to connect to local host in Heroku - WHY? heroku heroku

redis attempting to connect to local host in Heroku - WHY?


I had the same problem. Sidekiq 3+ does NOT automatically recongnize REDISTOGO_URL environment variable, instead REDIS_PROVIDER is used . I did a config reference by:

heroku config:set REDIS_PROVIDER=REDISTOGO_URL

then problem solved

I give detail explanation in my blog post


set up your redis.rb file as such :

 module MyApp   class << self     def redis       @redis ||= Redis.new(url: (ENV['REDISTOGO_URL'] || 'redis://127.0.0.1:6379'))     end   end end

in your sidekiq.rb do :

 Sidekiq.configure_server do |config|   Rails.logger = Sidekiq::Logging.logger   config.redis = { :url => MyApp.redis[:url], :namespace => 'sidekiq', :size => 5 } end Sidekiq.configure_client do |config|   config.redis = { :url => MyApp.redis[:url], :namespace => 'sidekiq', :size => 1 } end

this will ensure Sidekiq is picking up the Redis connection from your redis.rb init file.


The issue is with the ENV variable:

Per sidekiq's documentation:

RedisToGo can be used with the default REDISTOGO_URL env var in Sidekiq 2.x and earlier (REDISTOGO_URL is supported for legacy reasons, the REDIS_PROVIDER and REDIS_URL vars are recommended).

You must use the REDIS_PROVIDER or REDIS_URL ENV varibles instead of the REDISTOGO_URL for sidekiq 3 and up. You do not need a sidekiq initializer, and this code will do the trick:

Run the following from your terminal

heroku config:set REDIS_PROVIDER=redis://...........