如何让 Redis 在 Heroku 上启动?
我已在 Heroku 上添加了 Redistogo
nano 插件,并已在控制台中成功对其进行了测试。但是,当我的应用程序尝试连接 Redis 时,出现以下错误:
Heroku 日志文件:
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'
为什么它尝试访问本地主机上的 Redis?
我的 config/initializers 文件夹中的 Redis.rb 有这个,这几乎肯定是问题所在。
#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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你在使用Resque吗?如果是这样,您需要告诉 Resque 使用哪个 Redis。
如果没有,那么您发布的代码没有设置您的 REDIS 连接。
Are you using Resque? If so, you'll need to tell Resque which Redis to use.
If not, then the code you've posted about is NOT setting your REDIS connection up.
试试这个:
看看你的 REDISTOGO_URL 是什么。您可能不小心设置了它。
Try this:
to see what your REDISTOGO_URL is. You might have set it accidentally.