Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
blarralde opened this issue Jun 12, 2012 · 4 comments
Closed

Comments

@blarralde
Copy link

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

@ryansch
Copy link

ryansch commented Jun 20, 2012

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

@blarralde
Copy link
Author

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')

@icostan
Copy link

icostan commented Jun 22, 2012

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:pass@pike.redistogo.com:9005.

@blarralde
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants