简体   繁体   English

无法连接到 redis://localhost:6379/0:连接到 localhost:6379 时出现错误 111。 拒绝连接

[英]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.

相关问题 redis正在运行,但我得到“错误111连接到localhost:6379。 拒绝连接” - redis is running but I'm getting “Error 111 connecting to localhost:6379. Connection refused” Docker 上的 Redis:连接到 0.0.0.0:6379 时出现错误 111。 拒绝连接 - Redis on Docker: Error 111 connecting to 0.0.0.0:6379. Connection refused 连接到 localhost:6379 时出现错误 111。 连接被拒绝。 姜戈赫鲁库 - Error 111 connecting to localhost:6379. Connection refused. Django Heroku 引发 ConnectionError(self._error_message(e)) kombu.exceptions.OperationalError:连接到 localhost:6379 的错误 111。 拒绝连接 - raise ConnectionError(self._error_message(e)) kombu.exceptions.OperationalError: Error 111 connecting to localhost:6379. Connection refused docker-compose + django + redis-错误111连接到127.0.0.1:6379。 拒绝连接 - docker-compose + django + redis - Error 111 connecting to 127.0.0.1:6379. Connection refused OperationalError,连接到 127.0.0.1:6379 的错误 111。 拒绝连接。 在 heroku 中部署后 - OperationalError, Error 111 connecting to 127.0.0.1:6379. Connection refused. After deploying in heroku redis.exceptions.ConnectionError:连接到 localhost:6379 时出现错误 97。 协议不支持的地址族 - redis.exceptions.ConnectionError: Error 97 connecting to localhost:6379. Address family not supported by protocol NGINX 错误:连接到上游时连接()失败(111:连接被拒绝) - NGINX ERROR :connect() failed (111: Connection refused) while connecting to upstream Docker [Errno 111] 连接调用失败 ('127.0.0.1', 6379) - Docker [Errno 111] Connect call failed ('127.0.0.1', 6379) celery + redis 无法连接到 amqp://guest:**@127.0.0.1:5672//: [Errno 111] 连接被拒绝 - celery + redis Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 111] Connection refused
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM