title: deploying redis to heroku unable to connect
body: <p>ive been trying to get resque to work with heroku. i can successfully get it to work in development mode, however when i try pushing to heroku i get</p>
  
  <pre><code>Errno::ECONNREFUSED (Connection refused - Unable to connect to Redis on 127.0.0.1:6379):
  </code></pre>
  
  <p>i then read and followed <a href="http://blog.redistogo.com/2010/07/26/resque-with-redis-to-go/" rel="noreferrer">http://blog.redistogo.com/2010/07/26/resque-with-redis-to-go/</a></p>
  
  <p>i put the configurations listed in the site but got the following error</p>
  
  <pre><code>SocketError (getaddrinfo: nodename nor servname provided, or not known):
  </code></pre>
  
  <p>i put in my initializers/resque.rb</p>
  
  <pre><code>Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
  
  ENV["redis://redistogo:11111111111111111@lab.redistogo.com:9254/"] ||= "redis://heroku_username:heroku_password@host:9254/"
  uri = URI.parse(ENV["redis://redistogo:1111111111111111@lab.redistogo.com:9254/"])
  Resque.redis = Redis.new(:host =&gt; uri.host, :port =&gt; uri.port, :password =&gt; uri.password)
  </code></pre>
  
  <p>however it throws the error mentioned above. on my dev mode now, i get the error as well.</p>
  
  <p>i tried using my heroku username (im using the add on from heroku), putting my password to heroku, and changing the port to 9254. however i keep getting the socket error now. what am i doing wrong?</p>
  
  <p>help would be much appreciated. thank you</p>
  
  <p>UPDATE.</p>
  
  <p>@kevin</p>
  
  <p>i tried </p>
  
  <pre><code>uri = URI.parse(ENV["my_url_string"] || "redis://localhost:9254/" )
  REDIS = Redis.new(:host =&gt; uri.host, :port =&gt; uri.port, :password =&gt; uri.password)
  </code></pre>
  
  <p>in a initializer/redis.rb as well but i get the following error</p>
  
  <pre><code>Errno::ECONNREFUSED (Connection refused - Unable to connect to Redis on 127.0.0.1:6379):
  </code></pre>
  
  <p>are the numbers in the error, ie 127.0.0.1:6379 significant? ive checked my redis gui app and also from heroku config that my port number is 9254</p>
  
  <pre><code>REDISTOGO_URL       =&gt; redis://redistogo:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@lab.redistogo.com:9254/
  </code></pre>
  
  <p>did you have any other configuration settings? thanks for helping!</p>
  
  <p>FINAL UPDATE.</p>
  
  <p>i fixed it. i can't believe it! my complete solution is</p>
  
  <pre><code>uri = URI.parse(ENV["REDISTOGO_URL"])
  REDIS = Redis.new(:host =&gt; uri.host, :port =&gt; uri.port, :password =&gt; uri.password)
  Resque.redis = REDIS
  </code></pre>
  
  <p>verbatim. it works without explicitly setting the url because i guess heroku tries to set it up for me already</p>