celery启动异常: ERROR/MainProcess] consumer: Cannot connect to redis://192.168.1.164:6379/8: DENIED

异常如下: 

 

进入redis的配置文件中:

redis的保护模式关闭
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
# 受保护模式, 默认是开启的
# protected-mode yes
protected-mode no


# celery开启命令
celery -A celery名 worker -l info

 

 

 

 

(venv) root@dns-web:/opt/dash-fastapi-admin/dash-fastapi-backend# uvicorn server:app --host 0.0.0.0 --port 8000 --reload INFO: Will watch for changes in these directories: ['/opt/dash-fastapi-admin/dash-fastapi-backend'] INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) INFO: Started reloader process [439281] using WatchFiles Process SpawnProcess-1: Traceback (most recent call last): File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/usr/lib/python3.11/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/opt/dash-fastapi-admin/venv/lib/python3.11/site-packages/uvicorn/_subprocess.py", line 80, in subprocess_started target(sockets=sockets) File "/opt/dash-fastapi-admin/venv/lib/python3.11/site-packages/uvicorn/server.py", line 67, in run return asyncio.run(self.serve(sockets=sockets)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete File "/opt/dash-fastapi-admin/venv/lib/python3.11/site-packages/uvicorn/server.py", line 71, in serve await self._serve(sockets) File "/opt/dash-fastapi-admin/venv/lib/python3.11/site-packages/uvicorn/server.py", line 78, in _serve config.load() File "/opt/dash-fastapi-admin/venv/lib/python3.11/site-packages/uvicorn/config.py", line 436, in load self.loaded_app = import_from_string(self.app) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/dash-fastapi-admin/venv/lib/python3.11/site-packages/uvicorn/importer.py", line 19, in import_from_string module = importlib.import_module(module_str) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1206, in _gcd_import File "<frozen importlib._bootstrap>", line 1178, in _find_and_load File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 690, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 940, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/opt/dash-fastapi-admin/dash-fastapi-backend/server.py", line 3, in <module> from config.env import AppConfig File "/opt/dash-fastapi-admin/dash-fastapi-backend/config/env.py", line 55, in <module> class RedisSettings(BaseSettings): File "/opt/dash-fastapi-admin/venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 112, in __new__ private_attributes = inspect_namespace( ^^^^^^^^^^^^^^^^^^ File "/opt/dash-fastapi-admin/venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 459, in inspect_namespace raise PydanticUserError( pydantic.errors.PydanticUserError: A non-annotated attribute was detected: `CELERY_BROKER_URL = 'redis://:re111@192.168.118.164:6379/0'`. All model fields require a type annotation; if `CELERY_BROKER_URL` is not meant to be a field, you may be able to resolve this error by annotating it as a `ClassVar` or updating `model_config['ignored_types']`. For further information visit https://errors.pydantic.dev/2.11/u/model-field-missing-annotation 出什么错
最新发布
07-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值