25 days ago
Service Variables not injected into container at runtime
I have a service ("sistema-stock") deployed from a GitHub repo via Dockerfile (Root Directory: /backend). The container builds successfully but crashes on start because DATABASE_URL and other Service Variables are not present in the running container's environment.
I confirmed this by adding a temporary debug line to the container's start command that prints env | cut -d= -f1 | sort before the app starts. The output shows all of Railway's own auto-injected variables (RAILWAY_ENVIRONMENT_NAME=production, RAILWAY_SERVICE_NAME=sistema-stock, RAILWAY_PROJECT_NAME=resilient-cat, plus ~30 other RAILWAY_* variables) — so the service identity/environment is correct. However, none of the Service Variables I configured in the dashboard are present — not DATABASE_URL, not JWT_SECRET, and not even a brand-new test variable (TESTVAR=hello123) I added specifically to rule out any issue with the existing ones.
Things I've already tried:
Deleting and recreating the variables from scratch using "+ New Variable"
Using the Raw Editor
Referencing the linked Postgres plugin's DATABASE_URL via ${{Postgres.DATABASE_URL}} (also didn't resolve/inject)
Manually redeploying multiple times after each change
Only 2 variables appear to "work" (PORT and NODE_ENV), but that's misleading — those two also have hardcoded ENV defaults baked into the Dockerfile itself, so I can't confirm whether Railway is actually passing them through or whether the image's own defaults are just masking the same underlying problem.
Project: resilient-cat
Service: sistema-stock
Environment: production
Can you check on your end why Service Variables aren't being injected into this service's container at runtime?
1 Replies
25 days ago
Your 8 service variables (DATABASE_URL, JWT_SECRET, TESTVAR, and others) are currently staged but not yet applied. They show as pending changes in the dashboard and will not be injected into the container until you click the Deploy button on the bar at the bottom of the project canvas to commit them. Once you deploy those staged changes, the variables will be present in the container's environment.
Status changed to Awaiting User Response Railway • 25 days ago
18 days 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 • 18 days ago