Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Redis to start on Heroku?

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)
like image 570
Simpleton Avatar asked Oct 12 '11 08:10

Simpleton


2 Answers

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.

like image 113
Neil Middleton Avatar answered Nov 15 '22 20:11

Neil Middleton


Try this:

heroku config --long | grep REDIS

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

like image 22
Jonathan Avatar answered Nov 15 '22 21:11

Jonathan