【发布时间】:2011-12-05 22:28:02
【问题描述】:
我已经在 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)
【问题讨论】:
-
我猜 ENV["REDISTOGO_URL"] 是本地主机?尝试在生产中使用你的 heroku 域 url 作为这个变量。
-
Heroku 为您设置 REDISTOGO_URL 当您将插件添加为 redis to go 实例 URL 时
-
如果设置了 URL,为什么会尝试 localhost?
标签: ruby-on-rails heroku redis