[英]Can't connect to redis on heroku
我在 Rails 應用程序中使用 sidekiq 和 active_job。 該工作目前有效,但在部署到 heroku 時我無法連接到 Redis。 在 heroku 中,我有 RedisToGo 插件。 推送到 heroku 時,出現以下錯誤。
/app/vendor/bundle/ruby/2.2.0/gems/redis-3.2.1/lib/redis/client.rb:331:in `rescue in establish_connection': Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)
config.after_initialize do
PasswordAgingJob.perform_later
SetOffCallJob.perform_later
end
uri = URI.parse(ENV["REDISTOGO_URL"] || "redis://localhost:6379/" )
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
ActiveJob::Base.queue_adapter = :sidekiq
使用您的 Redis URL 將REDIS_PROVIDER
設置為環境REDIS_PROVIDER
的名稱。
輸入: heroku config:set REDIS_PROVIDER=REDISTOGO_URL
。 重新開始。
在這里解釋: https : //github.com/mperham/sidekiq/wiki/Using-Redis#using-an-env-variable
在heroku
配置中設置REDIS_URL
幫助我解決:
Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)
您必須在 Heroku 上設置REDISTOGO_URL
。
單擊設置,然后顯示配置變量。
將 REDIS_URL 設置為 redis://@pike.redistogo.com:10731/ 似乎對我有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.