Railway deployment keeps using old environment variables after I changed them
sania-ali
FREEOP

8 days ago

Hi,

I'm running into something strange with my Railway service. I changed a few environment variables in the production environment and redeployed, but the application is still picking up the old values.

For example, I changed:

API_URL=https://old-api.example.com

to:

API_URL=https://new-api.example.com

The dashboard shows the new value, and I triggered a new deployment afterwards.

But inside the running container:

printenv API_URL

still shows:

https://old-api.example.com

I also tried restarting the service, but it didn't change anything.

What's confusing is that another service in the same project picks up the new value correctly.

I checked the variables in the production environment and don't see another API_URL there.

Is Railway caching the environment variables, or is there somewhere else the old value could be coming from?

Solved$10 Bounty

Pinned Solution

ahmed1453
FREE

8 days ago

Hi,

Check the variable from inside the new deployment, not the old running container.

Also make sure you're editing the variable for the correct service + environment. Railway variables are applied when a new deployment is created.

If printenv API_URL still shows the old value after a completely new deployment, check your Dockerfile or .env files for something like:

ENV API_URL=https://old-api.example.com

If another service gets the new value correctly, I'd compare the two services' variable configuration first.

6 Replies

Railway
BOT

8 days ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway 8 days ago


8 days ago

Make sure you deployed the staged changes, If you have deployed and it is still serving the old values, Try Deploy Latest Commit from the Command Palette


ahmed1453
FREE

8 days ago

Hi,

Check the variable from inside the new deployment, not the old running container.

Also make sure you're editing the variable for the correct service + environment. Railway variables are applied when a new deployment is created.

If printenv API_URL still shows the old value after a completely new deployment, check your Dockerfile or .env files for something like:

ENV API_URL=https://old-api.example.com

If another service gets the new value correctly, I'd compare the two services' variable configuration first.


ahmed1453

Hi, Check the variable from inside the new deployment, not the old running container. Also make sure you're editing the variable for the correct service + environment. Railway variables are applied when a new deployment is created. If printenv API_URL still shows the old value after a completely new deployment, check your Dockerfile or .env files for something like: ENV API_URL=https://old-api.example.com If another service gets the new value correctly, I'd compare the two services' variable configuration first.

sania-ali
FREEOP

8 days ago

Thnaks Thats Work Amazing


sania-ali
FREEOP

8 days ago

Thanks, that worked. One more thing if I change an environment variable again, do I always need to create a new deployment for the updated value to be available?


ahmed1453
FREE

8 days ago

Yes, normally you need a new deployment after changing variables. A restart alone may still use the previous deployment's values.


sania-ali
FREEOP

8 days ago

Thanks For Info Means A lot


Status changed to Solved 0x5b62656e5d 7 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...