Service variables not injected into process — Runtime V2 active, os.environ only shows system variables
jokin1969
PROOP

22 days ago

Environment: Railway (production), Python/Flask app, deployed via Nixpacks

Problem:

None of my user-defined service variables reach the Python process at runtime. When I call dict(os.environ) inside the running app, I get exactly 55 variables — all system-level (Railway metadata, Nix paths, PATH, HOME, etc.) — and zero of the variables I have defined in the service's Variables panel.

I tested this with a trivial variable (TEST_JOKIN=hola123). It never appears in os.environ.

What I found:

The variable RAILWAY_BETA_ENABLE_RUNTIME_V2 is present in os.environ but was not set by me — it appears to be injected at the infrastructure level. I tried adding it as a user variable with value false, redeployed, and the problem persists (still 55 vars, still no user vars).

What I've ruled out:

  • The variables are correctly defined in the Railway dashboard (Variables panel, service scope).
  • There is no .env file, no variable filtering in railway.toml or nixpacks.toml.
  • The app starts and responds normally — it just can't see its own config (API keys, credentials, feature flags, etc.).
  • Setting RAILWAY_BETA_ENABLE_RUNTIME_V2=false as a user variable has no effect.

Question:

Is Runtime V2 being force-enabled on my service at the infrastructure level? Is there a way to opt out via the dashboard Settings UI? If Runtime V2 uses a snapshot/image model that doesn't inject user-defined variables into the running process, is there a workaround or a timeline for a fix?

Happy to share the full os.environ dump or service config if that helps diagnose.

$20 Bounty

2 Replies

Status changed to Open Railway 22 days ago


22 days ago

I had a very similar issue recently with a Python/Flask app on Railway.

In my case, the first thing I would check is whether the variables are being defined at the correct level and whether the service was redeployed after the change.

A few practical checks that helped me isolate this kind of problem:

1. Confirm the variable is set in the specific service Variables tab, not only at project/shared level.

2. Force a fresh redeploy after adding the variable. I’ve seen situations where the dashboard showed the variable, but the running process was still from an older deployment context.

3. Add a temporary debug route that does not expose values, only keys:

```python

@app.route("/debug/env")

def debug_env():

import os

return {

"count": len(os.environ),

"has_test_jokin": "TEST_JOKIN" in os.environ,

"has_database_url": "DATABASE_URL" in os.environ,

"keys": sorted([k for k in os.environ.keys() if k.startswith(("RAILWAY_", "TEST_", "DATABASE", "PORT"))])

}


jokin1969
PROOP

22 days ago

Thanks for the suggestions. I’ve already confirmed:

1. Variables are set at service level (not project/shared), confirmed in the Variables tab.

2. Multiple fresh redeployments done — each time the deployment Details tab shows “12 Service Variables” correctly staged.

3. I already have a more detailed debug endpoint running. It shows exactly 55 variables, all system/Nix/Railway metadata. Zero user-defined variables — including TEST_JOKIN=hola123, which is a simple string with no references.

The deployment knows about the 12 variables (they appear in the Details tab) but they never reach os.environ at runtime. RAILWAY_BETA_ENABLE_RUNTIME_V2 is present in the environment but was not set by me — it appears infrastructure-injected. This points to a Runtime V2 injection failure at the process level, not a configuration mistake on my end.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...