a year ago
Hello,
In my django app I'm using redis to run a task using celery worker and beater.
After deploying I get thses messages in the deploy logs:
Starting Container
2025-03-26 09:58:09,465 - comparaplan.celery - INFO - Successfully validated Redis URL: redis://default:mypassword@redis.railway.internal:6379
2025-03-26 09:58:09,468 - comparaplan.celery - INFO - Periodic tasks configured successfully
2025-03-26 09:58:09,584 - comparaplan.celery - INFO -
Redis Connection Successful (Attempt 1)
Operations to perform:
Apply all migrations: admin, auth, contact, contenttypes, django_celery_beat, mobile_subscriptions, prospectAlert, sessions
Running migrations:
No migrations to apply.
[2025-03-26 09:58:12 +0000] [1] [INFO] Starting gunicorn 23.0.0
[2025-03-26 09:58:12 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
[2025-03-26 09:58:12 +0000] [1] [INFO] Using worker: sync
[2025-03-26 09:58:12 +0000] [5] [INFO] Booting worker with pid: 5
2025-03-26 09:58:13,269 - comparaplan.celery - INFO - Successfully validated Redis URL: redis://default:mypassword@redis.railway.internal:6379
2025-03-26 09:58:13,277 - comparaplan.celery - INFO - Periodic tasks configured successfully
2025-03-26 09:58:13,498 - comparaplan.celery - INFO -
Redis Connection Successful (Attempt 1)
Until now it looks good.
I'm trigerring the celery task via a post request:
After loading new logs appear:
[ERROR] 2025-03-26 10:09:19,758 redis - Connection to Redis lost: Retry (0/20) now.
[CRITICAL] 2025-03-26 10:09:39,859 redis -
Retry limit exceeded while trying to reconnect to the Celery redis result store backend. The Celery application must be restarted.
Weird cause the first logs indicated that the connection was done.
I'm 100% sure I used the right REDIS_URL already.
My Procfile has the following content:
web: python manage.py migrate && gunicorn comparaplan.wsgi --bind 0.0.0.0:$PORT
worker: celery -A comparaplan worker --loglevel=info
beat: celery -A comparaplan beat --loglevel=info
5 Replies
a year ago
Btw the script works fine in local ..
Starting Container
REDIS_URL = redis://default:mypassword@redis.railway.internal:6379
2025-03-26 15:21:54,295 - comparaplan.celery - INFO - Periodic tasks configured successfully
2025-03-26 15:21:54,455 - comparaplan.celery - INFO -
Redis Connection Successful (Attempt 1)
2025-03-26 15:21:54,460 - comparaplan.settings - INFO - Attempting to connect to Redis URL: redis://de...ernal:6379
2025-03-26 15:21:54,537 - comparaplan.settings - INFO - Redis connection successful. Ping response: True
REDIS_URL = redis://default:mypassword@redis.railway.internal:6379
Current working directory: /app
Operations to perform:
Apply all migrations: admin, auth, contact, contenttypes, django_celery_beat, mobile_subscriptions, prospectAlert, sessions
Running migrations:
No migrations to apply.
[2025-03-26 15:21:57 +0000] [1] [INFO] Starting gunicorn 23.0.0
[2025-03-26 15:21:57 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
[2025-03-26 15:21:57 +0000] [1] [INFO] Using worker: sync
[2025-03-26 15:21:57 +0000] [5] [INFO] Booting worker with pid: 5
REDIS_URL = redis://default:mypassword@redis.railway.internal:6379
2025-03-26 15:21:57,507 - comparaplan.celery - INFO - Periodic tasks configured successfully
2025-03-26 15:21:57,585 - comparaplan.celery - INFO -
Redis Connection Successful (Attempt 1)
2025-03-26 15:21:57,693 - comparaplan.settings - INFO - Attempting to connect to Redis URL: redis://de...ernal:6379
2025-03-26 15:21:57,705 - comparaplan.settings - INFO - Redis connection successful. Ping response: True
REDIS_URL = redis://default:mypassword@redis.railway.internal:6379
Current working directory: /app
[INFO] 2025-03-26 15:22:09,094 views - Attempting to start scraping task
[ERROR] 2025-03-26 15:22:09,230 redis - Connection to Redis lost: Retry (0/20) now.
[ERROR] 2025-03-26 15:22:09,302 redis - Connection to Redis lost: Retry (1/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:11,426 redis - Connection to Redis lost: Retry (3/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:12,443 redis - Connection to Redis lost: Retry (4/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:14,563 redis - Connection to Redis lost: Retry (6/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:16,664 redis - Connection to Redis lost: Retry (8/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:17,701 redis - Connection to Redis lost: Retry (9/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:18,707 redis - Connection to Redis lost: Retry (10/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:19,753 redis - Connection to Redis lost: Retry (11/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:20,755 redis - Connection to Redis lost: Retry (12/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:21,795 redis - Connection to Redis lost: Retry (13/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:22,800 redis - Connection to Redis lost: Retry (14/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:23,843 redis - Connection to Redis lost: Retry (15/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:24,846 redis - Connection to Redis lost: Retry (16/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:25,874 redis - Connection to Redis lost: Retry (17/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:26,876 redis - Connection to Redis lost: Retry (18/20) in 1.00 second.
[ERROR] 2025-03-26 15:22:27,899 redis - Connection to Redis lost: Retry (19/20) in 1.00 second.
[CRITICAL] 2025-03-26 15:22:28,901 redis -
Retry limit exceeded while trying to reconnect to the Celery redis result store backend. The Celery application must be restarted.
What could be the issue ? The initiale connection to redis is good and then when I triger my task it lost the connection
10 months ago
If you're using ioredis, ensure the family option is set to 0 in your connection settings to allow dual-stack (IPv4 and IPv6) lookups. This can help if the connection issue is DNS-related. You can see more about handling this type of issue here.
Status changed to Awaiting User Response Railway • 11 months ago
chandrika
If you're using ioredis, ensure the family option is set to 0 in your connection settings to allow dual-stack (IPv4 and IPv6) lookups. This can help if the connection issue is DNS-related. You can see more about handling this type of issue here.
10 months ago
Hi Chandrika, Thanks for your answer. I'm not using ioredis. I'm using django for this project
Status changed to Awaiting Railway Response Railway • 11 months ago
10 months ago
The problem seems to be "{"status": "error", "message": "Failed to start task: invalid username-password pair or user is disabled."}
However I don't understand because my REDIS_URL containing the username and the password match the one from the redis variable on Raiwail
10 months ago
Hey there, will close this one out and chat in the other thread we have!
Status changed to Awaiting User Response Railway • 11 months ago
Status changed to Closed chandrika • 11 months ago