Critical Issue: Environment variables not being passed to deployment (Trial Plan)
alex63656
HOBBYOP

2 months ago

Hello Railway Team,

I've been trying to deploy a simple Python bot for several days on the trial plan, but I'm facing a persistent blocker: my application is unable to access any of the environment variables set in the service's "Variables" tab.

The deployment log consistently shows a critical error from my application's startup check (translated from Russian): CRITICAL:root:!!! ERROR: One or more environment variables (BOT_TOKEN, WEB_APP_URL, GEMINI_API_KEY) are not set!

This proves that os.getenv() is returning None for all variables, even though they are correctly saved in the Railway UI.

I have already tried every possible troubleshooting step multiple times:

  • Manual redeploys.

  • Deleting and recreating the service.

  • Deleting and recreating the entire project.

  • Using both the standard variable editor and the "Raw Editor".

  • Adding a Procfile.

None of these actions have resolved the issue.

I am considering upgrading to the Hobby plan to get this project running permanently, but I cannot justify paying for a subscription if such a fundamental feature as environment variables is not working on the trial plan.

Could you please investigate why the variables are not being injected into my deployment's environment? This seems to be a platform-side issue.

Thank you for your help.

$10 Bounty

8 Replies

Railway
BOT

2 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


alex63656
HOBBYOP

2 months ago

Пожалуйста, помогите с этим


Can you share a screenshot of the variables tab as well as your code to retrieve the variable and where you print it?


alex63656
HOBBYOP

2 months ago

Here's the code I use to retrieve the environment variables in my bot.py:

import os BOT_TOKEN = os.getenv('BOT_TOKEN') WEB_APP_URL = os.getenv('WEB_APP_URL') GEMINI_API_KEY = os.getenv('GEMINI_API_KEY')

All variable names are correct; I use os.getenv as shown.
My app fails to see them at runtime, though everything is set in the Railway Variables tab.

Attachments


samgordon

Can you share a screenshot of the variables tab as well as your code to retrieve the variable and where you print it?

alex63656
HOBBYOP

2 months ago

Please take a look


alex63656
HOBBYOP

2 months ago



BOT_TOKEN: None

WEB_APP_URL: None

GEMINI_API_KEY: None

--- END OF DIAGNOSIS ---

CRITICAL:root:!!! ERROR: One or more variables (BOT_TOKEN, WEB_APP_URL, GEMINI_API_KEY) were not found!


Doesn't look like those are deployed. Did you click deploy changes at the top?


samgordon

Doesn't look like those are deployed. Did you click deploy changes at the top?

alex63656
HOBBYOP

2 months ago

Yes, my friend, I clicked "Expand". But there's still an error in the logs.


Loading...