Unable to connect to redis on heroku

I am using sidekiq with active_job in my rails application. The job currently works, but I cannot connect to Redis when deploying to heroku. In heroku, I have a RedisToGo app. When I click on a hero, I get the following error.

Error

/app/vendor/bundle/ruby/2.2.0/gems/redis-3.2.1/lib/redis/client.rb:331:in `rescue in establish_connection': Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError) 

config /application.rb

 config.after_initialize do PasswordAgingJob.perform_later SetOffCallJob.perform_later end 

config / Initializers / redis.rb

 uri = URI.parse(ENV["REDISTOGO_URL"] || "redis://localhost:6379/" ) REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password) 

config / Initializers / active_job.rb

 ActiveJob::Base.queue_adapter = :sidekiq 
+5
source share
3 answers

Set REDIS_PROVIDER env var with the Redis URL.

Enter this: heroku config:set REDIS_PROVIDER=REDISTOGO_URL . Restart.

Clarification here: https://github.com/mperham/sidekiq/wiki/Using-Redis#using-an-env-variable

+11
source

You must set REDISTOGO_URL to Heroku.

Click Settings , and then Display Vars Configurations .

+2
source

Setting REDIS_URL in heroku config will help me decide:

 Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError) 
+1
source

All Articles