a month ago
Hi,
My backend service cannot read the DATABASE_URL environment variable.
Even when I set DATABASE_URL manually in the service variables, inside the container os.getenv("DATABASE_URL") returns None and the app crashes with:
RuntimeError: DATABASE_URL not set
I tried:
- manual variable
- reference variable
- generator
- restarting service
Nothing works consistently.
Backend and Postgres are in the same project.
Can you verify if the environment variables are correctly injected into the container?
Project: mnevi-backend
Environment: production
1 Replies
a month ago
Your deployment history shows a pattern that explains this: deployments are being cancelled before they complete. On January 31st, there were multiple rapid deploy-cancel cycles within a 12-minute window, with variable changes triggering new deployments every 3-4 minutes. When you change variables quickly in succession, each change triggers a new deployment that cancels the previous one. The variables only take effect once a deployment finishes successfully. Let a single deployment run to completion after setting DATABASE_URL, and the variable should be available to your application. If you're using a Dockerfile and need the variable during the build phase (not just runtime), you must declare it with ARG DATABASE_URL in your Dockerfile since Railway doesn't automatically inject variables at build time for Dockerfile builds.
Status changed to Awaiting User Response Railway • about 1 month ago
a month ago
This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!
Status changed to Solved Railway • 27 days ago