title: rails-Sidekiq-Redis : RuntimeError (nodename nor servname provided, or not known)
body: <p>I am trying to run a Rails app, using Sidekiq w Redis ..</p>
  
  <p>config/initializers/</p>
  
  <pre><code>Sidekiq.configure_server do |config|
    config.redis = { url: 'redis://redis:6379/1', namespace:      'delay_message_dev', driver: :hiredis }
  end
  
  Sidekiq.configure_client do |config|
    config.redis = { url: 'redis://redis:6379/1', namespace: 'delay_message_dev', driver: :hiredis }
  end
  </code></pre>
  
  <p>sidekiq-server is running ...  </p>
  
  <pre><code>The server is now ready to accept connections on port 6379
  </code></pre>
  
  <p>In my message_controller.rb , after creating the message in db , I run</p>
  
  <pre><code>DelayMessageWorker.perform_at(@message[:delay_until_time], @message[:id])
  </code></pre>
  
  <p>and my DelayMessageWorker class is </p>
  
  <pre><code>class DelayMessageWorker
    include Sidekiq::Worker
  
    def perform(*args)
  
      # Get the message object
      message = Message.find(message_id)
  
      # Send an email
      MessageMailer.delay.default(message.recipient_email, message.text)
  
      # Change the status of the Message object to `sent`
      message.sent = true
      message.save  
    end
  end
  </code></pre>
  
  <p>however running  on localhost in dev mode, I get </p>
  
  <p>(0.2ms)  begin transaction
        SQL (0.5ms)  INSERT INTO "messages"   (3.0ms)  commit transaction
     (3.0ms)  commit transaction<br>
      Completed 500 Internal Server Error in 393ms (ActiveRecord: 3.7ms)</p>
  
  <p>RuntimeError (nodename nor servname provided, or not known):
    app/controllers/messages_controller.rb:34:in <code>block in create'
    app/controllers/messages_controller.rb:31:in</code>create'</p>
  
  <p>the message is written in the DB, so the error comes form Sidekiq-Redis ?<br>
  thanks for suggestions</p>
  
  <p>UPDATE </p>
  
  <p>I modified my sidekiq.rb initialiser to get a correct redis host </p>
  
  <pre><code>redis = YAML::load(File.open("#{ Rails.root }/config/redis.yml"))[::Rails.env]
  
  Sidekiq.configure_server do |config|
    config.redis = { url: "redis://#{ redis['host'] }:#{ redis['port'] }/0", namespace: 'delay_message_dev', driver: :hiredis }
  end
  
  Sidekiq.configure_client do |config|
    config.redis = { url: "redis://#{ redis['host'] }:#{ redis['port'] }/0", namespace: 'delay_message_dev', driver: :hiredis }
  end
  </code></pre>