minimal django/celery/redis 在本地运行,但是当我在 python 上运行时,部署到 heroku 时会出现以下错误:
raise ConnectionError(self._error_message(e))
kombu.exceptions.OperationalError: Error 111 connecting to localhost:6379. Connection
refused.
这是我的应用程序目录中的tasks.py 文件:
from celery import Celery
import os
app = Celery('tasks', broker='redis://localhost:6379/0')
app.conf.update(BROKER_URL=os.environ['REDIS_URL'],
CELERY_RESULT_BACKEND=os.environ['REDIS_URL'])
@app.task
def add(x, y):
return x + y
需求.txt:
django
gunicorn
django-heroku
celery
redis
celery-with-redis
django-celery
kombu
我已将worker dyno设置为1。 有趣的是,我可以发誓它以前可以工作,但现在由于某种原因它不起作用。
最佳答案
这为我解决了这个问题,我忘记像这样在project/init.py中导入celery
from .celery import app as celery_app
__all__ = ("celery_app",)
关于django - 引发 ConnectionError(self._error_message(e)) kombu.exceptions.OperationalError : Error 111 connecting to localhost:6379. 连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58901925/