10 months ago
I am facing an issue when deploying my Flask application on Railway. The app fails to start, and I receive the following error:
The full stack trace shows that SQLAlchemy is trying to use the MySQLdb driver, despite having PyMySQL installed and specified in my requirements.txt.
Environment Setup
Tech stack:
Flask (version: 2.3.3)
Flask-SQLAlchemy (version: 3.1.1)
Gunicorn (version: 23.0.0)
PyMySQL (version: 1.1.0)
SQLAlchemy (version: 2.0.37)
Project structure:
Current
DATABASE_URL: The environment variableDATABASE_URLis set in Railway's settings but does not specify thepymysqldriver.
Steps Taken to Fix
Updated `DATABASE_URL
Verified that
PyMySQLis installed viarequirements.txt.Updated the Gunicorn command in the custom start command:
Tested locally, and the app works without issues.
Could you confirm whether Railway supports mysql+pymysql?
Is there anything else I need to configure in the deployment process to resolve this issue?
Any suggestions for further debugging?
ⓘ Deployment information is only viewable by project members and Railway employees.
2 Replies
10 months ago
Hello,
You have PyMySQL in your requirements.txt file, but you aren't using it anywhere in your code, instead you are using SQLAlchemy
Please make sure you are using only PyMySQL in your code.
Status changed to Solved brody • 10 months ago
