17
votes

I've added the Redistogo nano add-on on Heroku and I've tested it out in the console successfully. However when my app tries to connect with Redis I get the following error:

Heroku Log file:

2011-10-12T08:19:50+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - Unable to connect to Redis on 127.0.0.1:6379):
2011-10-12T08:19:50+00:00 app[web.1]:   app/controllers/sessions_controller.rb:14:in `create'

Why is it trying to access Redis on localhost?

My Redis.rb in the config/initializers folder has this, which is almost certainly the problem.

#What's pasted below is pasted ad verbatim. I don't know what to change the values to.

uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
2
I guess ENV["REDISTOGO_URL"] is localhost? Try to using you heroku domain url for this variable in production.Mikhail Nikalyukin
Heroku set REDISTOGO_URL for you when you add the addon to be the redis to go instance URLJohn Beynon
If it's set the URL, why would it be attempting localhost?Simpleton

2 Answers

21
votes

Are you using Resque? If so, you'll need to tell Resque which Redis to use.

Resque.redis = REDIS

If not, then the code you've posted about is NOT setting your REDIS connection up.

6
votes

Try this:

heroku config --long | grep REDIS

to see what your REDISTOGO_URL is. You might have set it accidentally.