[英]Cannot connect to redis://localhost:6379/0: Error 111 connecting to localhost:6379. Connection refused
I've deployed a minimal django/celery/redis project to heroku, and I'm trying to test it in the python shell:我已经将一个最小的 django/celery/redis 项目部署到 heroku,我正在尝试在 python shell 中对其进行测试:
heroku run python
>>> import tasks
>>> tasks.add.delay(1, 2)
The problem is tasks.add.delay(1,2) doesn't produce any output, it just hangs there whereas in local it gave an Async message.问题是 tasks.add.delay(1,2) 没有产生任何 output,它只是挂在那里,而在本地它给出了一条异步消息。
Also when i try to see the task running in application logs with "heroku logs -t -p worker"此外,当我尝试使用“heroku logs -t -p worker”查看应用程序日志中运行的任务时
it gives me this error:它给了我这个错误:
ERROR/MainProcess] consumer: Cannot connect to redis://localhost:6379/0: Error 111
connecting to localhost:6379. Connection refused..
PS. PS。 It works fine on local.
它在本地运行良好。
Turns out i was missing the following in my tasks.py file in my application directory.原来我在我的应用程序目录中的 tasks.py 文件中缺少以下内容。
import os
app.conf.update(BROKER_URL=os.environ['REDIS_URL'],
CELERY_RESULT_BACKEND=os.environ['REDIS_URL'])
added that and now everything works.补充说,现在一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.