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

4 hours 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

1 Replies

Status changed to Open Railway about 4 hours ago


brparra
HOBBY

2 hours 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"))])

}


Welcome!

Sign in to your Railway account to join the conversation.

Loading...