a month ago
Railway Environment Variables Not Working
Problem: Railway deployment shows "successful" but FastAPI app crashes with ValidationError: Field required for environment variables.
Issue: Environment variables are set in Railway dashboard but not being injected into the running container.
Error: POSTGRESQL_USER, POSTGRESQL_PASSWORD, COGNITO_USER_POOL_ID, etc. all showing as "Field required" even though they exist in Railway Variables tab.
Question: Why aren't Railway environment variables being loaded by Pydantic Settings in production, and how do I fix this?
2 Replies
a month ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
a month ago
Did you set the variable in the service or as shared variables?
if you added them as shared variables you should probably want to set them in the service or follow this guide:
https://docs.railway.com/guides/variables#shared-variables