redis
redis copied to clipboard
redis.exceptions.AuthenticationError: Client sent AUTH, but no password is set
I use this in my docker-compose.yml:
# Redis (Results Backend & Cache)
redis:
image: redis:8.2.1-alpine
ports:
- "6379:6379"
volumes:
- redis-data:/data
env_file:
- ./env/.env.redis
networks:
- backend
restart: always
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 1m30s
timeout: 30s
retries: 5
start_period: 30s
command: redis-server --appendonly yes --requirepass redis_password
ERROR:
> uvicorn src.main:app --reload --port 5000 --host 0.0.0.0
INFO: Uvicorn running on http://0.0.0.0:5000 (Press CTRL+C to quit)
INFO: Started reloader process [5596] using WatchFiles
INFO: Started server process [11628]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: 127.0.0.1:57702 - "GET /api/v1/ping HTTP/1.1" 200 OK
INFO: 127.0.0.1:57702 - "POST /api/v1/projects/be09ca5cbaa14f0fa8a5ac9ffadcdad0/chunks HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
...
redis.exceptions.AuthenticationError: Client sent AUTH, but no password is set
Can anyone help?
More info about my setup: .env.redis file:
REDIS_PASSWORD=redis_password
REDIS_APPENDONLY=yes
REDIS_MAXMEMORY=512mb
REDIS_MAXMEMORY_POLICY=allkeys-lru
REDIS_PROTECTED_MODE=yes
redis url in .env file:
CELERY_RESULT_BACKEND_URL="redis://:redis_password@localhost:6379/0"
Hi @MohamedMostafa259!
redis:8.2.1-alpine definitely supports auth using --requirepass
What looks strange to me is that here
CELERY_RESULT_BACKEND_URL="redis://:redis_password@localhost:6379/0"
localhost is used but according to your config snippet above redis should be started on another host in the docker network, so it should be
CELERY_RESULT_BACKEND_URL="redis://:redis_password@redis:6379/0"
Also note that healthcheck may not work since redis-cli should use password, consider updating command to use password
healthcheck:
test: ["CMD", "redis-cli", "-a", "redis_password", "ping"]