Resque: "SocketError - getaddrinfo: Name or service not known" on production

Created on 12 Jun 2012  路  4Comments  路  Source: resque/resque

Hello,

I get the error in title on my production server. I've sourced it and it comes from Resque.redis in lib/resque.rb, and more precisely @redis. Somehow @redis doesn't get correctly initialized, so I've made that hacky patch:

  def self.redis
    if @defined.nil?
      self.redis = Redis.respond_to?(:connect) ? Redis.connect : "localhost:6379"
      @defined = true
    else
      return @redis
    end
    self.redis
  end

And it works. Any opinion on this?

Cheers,
Ben

All 4 comments

I'd be interested to see your redis/resque initializer.

Here you go:
Redis

$redis = Redis.new(:host => 'localhost', :port => 6379)

Resque

require 'resque'
require 'resque_scheduler'

config = YAML.load_file(Rails.root.join('config', 'resque.yml'))
cron = YAML.load_file(Rails.root.join('config', 'cron.yml'))

# configure redis connection
Resque.redis = config[Rails.env]

# configure the schedule
Resque.schedule = cron

#patch for redis
require File.join(Rails.root, 'lib/resque_redis_fix.rb')

It happened to me also for one application deployed on heroku but strange thing is that it works in another app, pretty much the same configs.

What is your redis url from resque.yml file? I use something like this: redis://user:[email protected]:9005.

Oh God.. Just realized this file contained the following:

development: localhost:6379
staging: localhost:6379
test: localhost:6379
production: production_db_server_address:6379

No wonder it worked in dev but not prod... I'll close the issue then, sorry for the bother.

Was this page helpful?
0 / 5 - 0 ratings