Reputation: 1518
I'm a novice Rails dev building an app connected to redis + sidekiq. I must have some configuration error, but I'm not sure what exactly it is. Below, I'll write about what exactly confuses me here:
Upon running rails s, I get the following error:
2016-07-09 08:55:46 - SocketError - getaddrinfo: nodename nor servname provided, or not known:
/Users/rohitrekhi/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis/connection/ruby.rb:177:in `getaddrinfo'
/Users/rohitrekhi/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis/connection/ruby.rb:177:in `connect'
/Users/rohitrekhi/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis/connection/ruby.rb:260:in `connect'
/Users/rohitrekhi/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis/client.rb:336:in `establish_connection'
So I figured it must be a redis connection error. When I ping redis to see if connection goes through, it shows the following:
$ redis-cli ping
=> PONG
So if the redis connection goes through, maybe it's a Sidekiq issue?
I implemented the Sidekiq web interface via Sinatra, and got the following error when I tried to view it:
SocketError at /sidekiq/
getaddrinfo: nodename nor servname provided, or not known
So now I'm guessing the error is actually via Sidekiq, but I'm not sure where I dropped the ball via configurations on the host/server/sockets. Any ideas what exactly is causing this and if it's an error with Sidekiq or redis?
This is my initializer file for sidekiq in config/initializers/sidekiq.rb:
Sidekiq.configure_server do |config|
config.redis = { url: 'redis://redis.example.com:6379/12', network_timeout: 5 }
end
Sidekiq.configure_client do |config|
config.redis = { url: 'redis://redis.example.com:6379/12', network_timeout: 5 }
end
And this is my config/initializer/redis.rb:
$redis = Redis.new(:host => 'localhost', :port => 6379)
I've also opened three terminal windows turning on the redis server, sidekiq, and my rails server.
Thanks in advance!
Upvotes: 2
Views: 4629
Reputation: 22208
This makes no sense:
redis://redis.example.com:6379/12
You do not have a Redis server at that URL; fix the URL.
Upvotes: 3