celery报连接错误进程守护无法连接Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 111] Connection refuse

本文解决Celery连接RabbitMQ时出现的“Connection refused”错误,提供了检查和安装RabbitMQ的方法,以及调整Celery版本以确保与RabbitMQ版本兼容的指导。
一、文章贡献

安装rabbitMQ的部分,来自于
https://www.jb51.net/article/174857.htm

二、报错信息
Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 111] Connection refused

有的是执行这行代码时报错

celery -A celery_tasks.main worker -l info

有些是执行上面代码成功连接,但是执行下面进程守护的时候报错

celery multi start w1 -A celery_tasks.main -l info --logfile=./celerylog.log --pidfile=./celerypid.pid
三、提供两个可能导致错误的原因和方案
1.没有安装rabbitMQ,下面提供安装方法

首先查看系统内是否有rabbitmq

ps 
[2025-08-20 19:43:04,809: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: timed out. Trying again in 2.00 seconds... (1/100) [2025-08-20 19:43:08,252: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672// [2025-08-20 19:43:12,258: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: timed out. Trying again in 2.00 seconds... (1/100) [2025-08-20 19:43:16,268: INFO/MainProcess] mingle: searching for neighbors /usr/local/lib/python3.11/site-packages/click/core.py:1193: UserWarning: The parameter --uid is used more than once. Remove its duplicate as parameters should be unique. parser = self.make_parser(ctx) /usr/local/lib/python3.11/site-packages/click/core.py:1186: UserWarning: The parameter --uid is used more than once. Remove its duplicate as parameters should be unique. self.parse_args(ctx, args) /usr/local/lib/python3.11/site-packages/celery/platforms.py:840: SecurityWarning: You're running the worker with superuser privileges: this is absolutely not recommended! Please specify a different user using the --uid option. User information: uid=0 euid=0 gid=0 egid=0 warnings.warn(SecurityWarning(ROOT_DISCOURAGED.format( -------------- celery@common_worker v5.2.7 (dawn-chorus) --- ***** ----- -- ******* ---- Linux-6.1.0-37-cloud-amd64-x86_64-with-glibc2.36 2025-08-20 19:43:24 - *** --- * --- - ** ---------- [config] - ** ---------- .> app: common:0x7fc58a87d990 - ** ---------- .> transport: amqp://guest:**@localhost:5672// - ** ---------- .> results: disabled:// - *** --- * --- .> concurrency: 2 (prefork) -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) --- ***** ----- -------------- [queues] .> common exchange=common(direct) key=common [tasks] . tasks.common.common_tasks.process [2025-08-20 19:43:28,604: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: timed out. Trying again in 2.00 seconds... (1/100) [2025-08-20 19:43:32,253: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672// [2025-08-20 19:43:36,262: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: timed out. Trying again in 2.00 seconds... (1/100) [2025-08-20 19:43:40,260: INFO/MainProcess] mingle: searching for neighbors /usr/local/lib/python3.11/site-packages/click/core.py:1193: UserWarning: The parameter --uid is used more than once. Remove its duplicate as parameters should be unique. parser = self.make_parser(ctx) /usr/local/lib/python3.11/site-packages/click/core.py:1186: UserWarning: The parameter --uid is used more than once. Remove its duplicate as parameters should be unique. self.parse_args(ctx, args) /usr/local/lib/python3.11/site-packages/celery/platforms.py:840: SecurityWarning: You're running the worker with superuser privileges: this is absolutely not recommended! Please specify a different user using the --uid option. User information: uid=0 euid=0 gid=0 egid=0 warnings.warn(SecurityWarning(ROOT_DISCOURAGED.format( -------------- celery@common_worker v5.2.7 (dawn-chorus) --- ***** ----- -- ******* ---- Linux-6.1.0-37-cloud-amd64-x86_64-with-glibc2.36 2025-08-20 19:43:48 - *** --- * --- - ** ---------- [config] - ** ---------- .> app: common:0x7f17a9df4b10 - ** ---------- .> transport: amqp://guest:**@localhost:5672// - ** ---------- .> results: disabled:// - *** --- * --- .> concurrency: 2 (prefork) -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) --- ***** ----- -------------- [queues] .> common exchange=common(direct) key=common [tasks] . tasks.common.common_tasks.process [2025-08-20 19:43:52,581: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: timed out. Trying again in 2.00 seconds... (1/100) [2025-08-20 19:43:56,254: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672// [2025-08-20 19:44:00,265: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: timed out. Trying again in 2.00 seconds... (1/100)
08-21
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值