Try to search your question here, if you can't find : Ask Any Question Now ?

Heroku connects to Redis localhost when calling Resque.enqueue in Rails 4 application

HomeCategory: stackoverflowHeroku connects to Redis localhost when calling Resque.enqueue in Rails 4 application
Avatarbhawya asked 4 months ago

In Heroku when the Resque.enqueue command is run Heroku attempts to connect to redis via localhost. In the config/initializers/redis.rb the correct URL is set with $redis = Redis.new(url: ENV[‘REDIS_URL’]) and $redis is instantiated without error. In the controller where the enqueue method is called $redis.inspect returns the correct value.

The error received is: Redis::CannotConnectError (Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)):

gemfile

gem 'rails', '4.2.6' 
gem 'redis', "~> 4.1.0"
gem 'resque', "~> 1.27.3"

config/initializers/redis.rb

if Rails.env.production?
  $redis = Redis.new(url: ENV['REDIS_URL'])
  puts "$redis.inspect => #{$redis.inspect} "
end

lib/tasks/resque.rake

require "resque/tasks"
task "resque:setup" => :environment

rakefile
task “resque:preload” => :environment

procfile

web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker: env QUEUE=* bundle exec rake resque:work
1 Answers
Best Answer
AvatarArben answered 4 months ago
Your Answer

4 + 10 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com