title: Redis::TimeoutError in Rails application
body: <p>I keep getting Redis::Timeout error in my application (both in UI and in background jobs). I am using AWS ElastiCache service for Redis.</p>
  
  <p>This is how I create a Redis connection. In my config/application.rb , I have:</p>
  
  <pre><code>$redis = Redis.new(host: REDIS_HOST, port: REDIS_PORT, db: REDIS_DB)
  </code></pre>
  
  <p>How can I avoid getting timeout errors? I am using the default connection settings as follows:</p>
  
  <pre><code>&gt; $redis.client.options[:reconnect_attempts]
   =&gt; 1 
  &gt; $redis.client.options[:timeout]
   =&gt; 5.0 
  &gt; $redis.client.options[:tcp_keepalive]
   =&gt; 0 
  &gt; $redis.client.options[:inherit_socket]
   =&gt; false
  </code></pre>