Connection refused for Redis on Heroku

一世执手 提交于 2019-12-11 08:09:11

问题


I'm trying to set up Redis on Heroku as a backend for Celery. I have it working locally but on Heroku, I get this error (after the celery task completes): ConnectionError: Error 111 connecting localhost:6379. Connection refused.

From what I can tell from other answers, that would indicate that the redis server isn't online, though the REDISTOGO_URL seems to be configured properly.

In settings.py:

REDIS_URL = os.getenv('REDISTOGO_URL', 'redis://localhost:6379/0')

In tasks.py:

from celery import Celery
celery = Celery('tasks', backend=settings.CELERY_RESULT_BACKEND, broker=settings.REDIS_URL)

Versions:

celery==3.0.5
celery-with-redis==3.0
django-celery==3.0.4
kombu==2.3.2
redis==2.6.0

回答1:


Looks like you're not using REDISTOGO_URL, since the error message states localhost

Try to check:

  1. heroku config, just to check that REDISTOGO_URL is set in config
  2. Go to shell on heroku (like this) and see if python gets url correctly

Do you run celery on the same app, if not check that other server's config.




回答2:


Found the problem. I had the celery backend configured to the string 'redis' rather than the REDIS_URL.

What I had:

CELERY_RESULT_BACKEND = 'redis'

What it should be:

CELERY_RESULT_BACKEND = REDIS_URL

Dmitry - appreciate your help.



来源:https://stackoverflow.com/questions/11813470/connection-refused-for-redis-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!