6 days ago
Hello,
I'm having trouble deploying my Python application on Railway.
Project: dazzling-art
Environment: production
Service: deskon
Database: PostgreSQL
Issue:
My service repeatedly crashes because Python cannot access custom environment variables.
Both variables are visible in Railway's deployment details:
- DATABASE_URL: References the Postgres service's DATABASE_URL
- DESKON_ENV_TEST: Set to "hello"
However, the deployment logs show:
DATABASE_URL present = False
DESKON_ENV_TEST present = False
RAILWAY_ENVIRONMENT present = True
RAILWAY_ENVIRONMENT_NAME present = TrueThe application exits with:
Configure DATABASE_URL before starting the cloud test service.Configuration:
- Dockerfile uses Python 3.12 and runs
python start.py. - Railway builds using Dockerfile.
- PostgreSQL service is Online.
- I have redeployed multiple times.
- The variables appear in the deployment details but are unavailable through Python's
os.getenv().
Could you help me determine why the custom environment variables are not reaching the application container?
Thank you!
1 Reply
6 days ago
Both variable names on the deskon service begin with a leading tab character, so the container receives them as \tDATABASE_URL and \tDESKON_ENV_TEST rather than DATABASE_URL and DESKON_ENV_TEST. That is why os.getenv("DATABASE_URL") comes back empty even though the variables appear in the deployment details.
To fix it, open the deskon service's Variables tab, delete both variables, and re-add them with the names typed fresh (not pasted), with DATABASE_URL set to the reference ${{Postgres.DATABASE_URL}} and DESKON_ENV_TEST set to hello. Then deploy the staged changes.
Status changed to Awaiting User Response Railway • 6 days ago