Environment variables not available in runtime
arthurcher
FREEOP

8 months ago

Hello Railway Support,

I'm experiencing a critical issue: environment variables I add in the “Variables” section of my project are not available at runtime inside my deployed app.

Specifically, I'm using os.getenv("OPENAI_API_KEY") in Python, but print(repr(os.getenv("OPENAI_API_KEY"))) always returns None, even though the variable is correctly set in Railway under that exact name.

What I've tried:

  • Variable is named exactly: OPENAI_API_KEY

  • Confirmed it's saved and visible in Railway UI

  • No .env file is present in the repo

  • No load_dotenv() call in the code

  • Redeployed the project manually multiple times

Still, the variable is not available at runtime.
This breaks my integration with OpenAI Assistants API.

Could you please help me verify why the environment variable is not reaching the runtime container?

Thanks in advance!

Solved

1 Replies

echohack
EMPLOYEE

8 months ago

Hi arthur,

You need to click the deploy button to make the staged changes to your variables available in the environment.

Best,
Railway Support


Status changed to Awaiting User Response Railway 8 months ago


Railway
BOT

6 months 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 6 months ago


Loading...