3 days ago
Hi Railway Support Team,
I hope you’re doing well.
I am reaching out regarding a deployment issue I’ve been experiencing with my FastAPI backend project (using FastAPI + Pydantic v2) on Railway. Every time I attempt to deploy, the process crashes with the following error:
ModuleNotFoundError: No module named 'pydantic_settings'
File "/app/app/core/config.py", line 6, in <module>
from pydantic_settings import BaseSettings
Steps I Have Taken So Far:
• I have added pydantic-settings (with a dash, not an underscore) to my requirements.txt.
• After committing and pushing the changes, Railway triggers a new deployment and reads the latest requirements.
• I have deleted and reinstalled all dependencies locally—everything works fine in my local .venv environment.
• I confirmed there are no duplicate or conflicting requirements files; only requirements.txt is present.
• I have cleared the Railway build cache and redeployed from scratch.
• Both my Python version and pip are up to date.
• The backend works perfectly in my local environment, but the Railway deployment consistently fails with this missing module.
My Analysis:
• It appears Railway is either not installing pydantic-settings, or there may be an issue during the dependency installation step.
• There may also be a configuration quirk, or perhaps the wrong requirements file is referenced during build.
• Since I am using FastAPI with Pydantic v2, pydantic-settings is required for the new BaseSettings import.
What I Would Appreciate Help With:
1. Could you please confirm that Railway is installing all dependencies from requirements.txt, especially pydantic-settings?
2. Are there any special steps, workarounds, or build settings required for FastAPI + Pydantic v2 projects on Railway?
3. If possible, could you provide more detailed logs regarding dependency installation, or suggest additional troubleshooting steps?
4. Could you also confirm which requirements file Railway is referencing at build time?
I am happy to provide the full logs, my requirements.txt content, and any other files or screenshots you might need.
My goal is simply to achieve a stable deployment so my frontend can connect to my backend API on Railway.
Thank you very much for your help!
Best regards,
Jorge
Project: swmusic-backend
GitHub repository: https://github.com/SwStudioAI/swmusic-backend.git
1 Replies
3 days ago
Hey there! We've found the following might help you get unblocked faster:
🧵 Application failed to respond after successful deployment - FastAPI
🧵 Application Crashes on Deployment - ModuleNotFoundError for MySQLdb
If you find the answer from one of these, please let us know by solving the thread!
Status changed to Solved swstudioai • 3 days ago