20 days ago
Hello Railway Team,
I'm facing a series of critical issues with my Flask application and would be very grateful for your expert advice. My project is poetic-harmony.
The Core Problem:
My deployments are consistently failing with a WORKER TIMEOUT error. This seems to be the root cause of all other issues. The timeout triggers a chaotic loop of database initializations, and the application becomes unstable.
Symptom 1: Inconsistent Translations
- My primary issue is that my Flask-Babel translations are not working correctly. Some texts are translated, while others are not, and it changes on page refresh.
- I've confirmed my .po and .mo files are correct and the pybabel compile command runs successfully during the build. I suspect the WORKER TIMEOUT is preventing the locale from being loaded consistently.
Symptom 2: Email Delivery Failure (SMTP)
- My application also fails to send emails via Zoho SMTP.
- I have triple-checked all my environment variables MAIL_SERVER, MAIL_PORT, SUPPORT_EMAIL, SUPPORT_EMAIL_PASS, etc.), and they are correct.
- I've also confirmed with my domain provider (Namecheap) and Zoho that my DNS records (SPF, DKIM) are now set up correctly.
- I believe the WORKER TIMEOUT is causing the application to crash before it can even establish an SMTP connection.
What I've Tried:
I've spent a long time debugging this. The key issue seems to be the slow startup process, likely caused by my database initialization code running at the global scope of my run.py file.
My Question:
What is the standard, recommended Railway practice to initialize a database for a Flask application to avoid the WORKER TIMEOUT error? I believe if I can solve the timeout issue, the translation and email problems will be resolved as a consequence.
Thank you for your time and help.
1 Replies
19 days ago
your app is failing because the database starts inside the main process, flask blocks on startup until that code runs, and then gunicorn sees no response and kills the worker.
you should move all your db setup into a function, and run it when the app starts serving requests. you can read up on the flask factories and what's happening with gunicorn on your app. you should also be familiar with alembic migrations