a month ago
Hi Railway team,
I’m experiencing an issue where environment variables are not being injected into my Web Service container, even though they are correctly defined in the service‑level Variables panel.
Here are the key details:
1. Variables are defined in the correct location All variables (e.g., TEST_VAR, DB_URL, SECRET_KEY, CLIENT_SECRET) are set under: Architecture → Web Service → Variables There are no variables defined at the project level.
2. After redeploying, the container still receives None for all variables My logs show:
TEST_VAR: none
DB_URL : None
3. This leads to a runtime crash Because DB_URL is None, psycopg2 attempts to connect to a local socket:
psycopg2.OperationalError: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed
4. What I’ve already done
Created a brand‑new GitHub repo
Connected the new repo to this Railway project
Cleaned up duplicate variables
Ensured variables exist only in the Web Service
Redeployed multiple times
Verified that the variable names match exactly
Confirmed the app prints environment variables at startup
Despite this, the container still receives None for every variable.
5. What I need help with It appears that the Web Service is not receiving any environment variables at runtime. Could you please check the backend logs for this project and confirm whether variable injection is failing on the platform side?
Project URL:https://oauth-1-production.up.railway.app
6 Replies
a month ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open Railway • about 1 month ago
a month ago
Tried SSH-ing into the container and echo-ed your variables to make sure it exists? (eg, echo $DB_URL)
a month ago
If you are deploying via a Dockerfile, and setting ARG for env variables, they will be only available during the build process. Try removing ARG and ENV inside the Dockerfile, as you don't need them, because Railway injects env variables automatically into the container.
a month ago
thanks for your responses. I will respond only to the first comment at this time. So you know i work on a mac m1 and i am new to your service. I typically run iterm2 for ssh ing on my mac. I could not find the terminal on your website, but in the process of looking for it, i deployed the project and it appears to be working. however, i still do not know where your terminal is for ssh use. Thanks for the responses. I’m replying to the first comment for now so I can keep the thread organized.
For context, I’m on a Mac M1 and normally use iTerm2 for SSH, but I understand Railway uses its own in‑browser terminal. I’ve looked through the Web Service page and the deployment/log views, but I’m only seeing the read‑only build/crash terminal. I don’t see a Shell/SSH/Console tab anywhere, so I’m not sure where the interactive terminal is located.
While searching for it, I triggered a redeploy and the service is now running, but I still don’t know where to access the interactive terminal you mentioned for running commands like echo $DB_URL. Could you point me to the exact location in the UI?
a month ago
sorry if my message was confusing above. i am at work multi tasking
rickthecoder1234
thanks for your responses. I will respond only to the first comment at this time. So you know i work on a mac m1 and i am new to your service. I typically run iterm2 for ssh ing on my mac. I could not find the terminal on your website, but in the process of looking for it, i deployed the project and it appears to be working. however, i still do not know where your terminal is for ssh use. Thanks for the responses. I’m replying to the first comment for now so I can keep the thread organized.For context, I’m on a Mac M1 and normally use iTerm2 for SSH, but I understand Railway uses its own in‑browser terminal. I’ve looked through the Web Service page and the deployment/log views, but I’m only seeing the read‑only build/crash terminal. I don’t see a Shell/SSH/Console tab anywhere, so I’m not sure where the interactive terminal is located.While searching for it, I triggered a redeploy and the service is now running, but I still don’t know where to access the interactive terminal you mentioned for running commands like echo $DB_URL. Could you point me to the exact location in the UI?
a month ago
You will need to install Railway CLI (https://docs.railway.com/guides/cli). You can then right click your service and select "Copy SSH Command" to SSH into your service.
Also, before we do that, I'd make sure all the variables are properly defined in your web service in your Railway GUI.
a month ago
I did install the CLI. thanks for the update there. Currently, the issue : Environment Variables Not Injecting Into Web Service Container , appears to be solved, so thank you. I still have a bug or 2, so will update you in the next day or so if needed.