I had huge issues with starting sidekiq on Heroku after updating my gems and putting everything into production. The problem was that Sidekiq tried to connect to Redis on a local connection and port, instead of using the REDISTOGO variable. After spending a few hours, I managed to fix it: Answer below.
3 Answers
Remove everything from the if and below and run this:
heroku config:set REDIS_PROVIDER=REDISTOGO_URL
Sidekiq will automatically use it.

- 21,300
- 6
- 59
- 61
-
I am using Rails 4.1.0 and tried this command. But still I get redis connect error. Any idea? – Soundar Rathinasamy Aug 25 '15 at 06:39
-
4OMG. This is a great confusion. I set REDIS_PROVIDER="redis://....". But it should be REDIS_PROVIDER=REDISTOGO_URL – Soundar Rathinasamy Aug 25 '15 at 07:15
-
1Yes, that's what it says. :-) You are telling it the name of the variable to use to find the Redis URL. – Mike Perham Aug 25 '15 at 13:28
-
you know what @MikePerham , you are a life saver – Ahmed Reza Siddique Jul 15 '17 at 12:33
I looked up the correct, new connection that RedisToGo provides and then inserted it into the variables. Some posts here on SO claimed that this wasn't necessary, but it seems it is.
My sidekiq.rb file in the initializers now looks like this, everything works.
require 'sidekiq/web'
Sidekiq.configure_server do |config|
ActiveRecord::Base.configurations[Rails.env.to_s]['pool'] = 30
end
if Rails.env.production?
Sidekiq.configure_server do |config|
config.redis = { url: ENV["REDISTOGO_URL"]}
end
Sidekiq.configure_client do |config|
config.redis = { url: ENV["REDISTOGO_URL"]}
end
end

- 1,074
- 2
- 12
- 27
Not an answer - but want to add to the SEO for this post so others can find this. This is also the answer to an issue where heroku will throw the error:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
This issue has been unanswered on many SO questions (example), and everyone says the database isn't correctly configured, which is not necessarily the case.
I tried for hourrrrsss to figure out the issue, and this was the solution! Thank you so much - I wish I could upvote your answers more than once!!

- 1,418
- 2
- 30
- 60