Environment variables are not available at runtime
usmcrobloxwinro-droid
FREEOP

19 days ago

Hello,

I'm deploying a Node.js Discord bot on Railway.

My environment variables are configured in the Variables tab for the service (DISCORD_TOKEN, CLIENT_ID, GUILD_ID, etc.). They have values and were saved.

However, when the application starts, none of the environment variables are available.

I added this debug code:

console.log("DISCORD_TOKEN exists:", !!process.env.DISCORD_TOKEN);

console.log("CLIENT_ID exists:", !!process.env.CLIENT_ID);

console.log("Environment keys:", Object.keys(process.env).filter(k =>

k.includes("TOKEN") || k.includes("CLIENT")

));

The runtime output is:

DISCORD_TOKEN exists: false

CLIENT_ID exists: false

Environment keys: []

The application then exits with:

[CONFIG] Missing required environment variable(s): DISCORD_TOKEN, CLIENT_ID

The variables are configured on the service, not just in the repository, and I'm deploying from GitHub.

Could you help determine why no environment variables are being injected into the runtime?

Thank you.

Solved

1 Replies

Railway
BOT

19 days ago

Your five environment variables (DISCORD_TOKEN, CLIENT_ID, GUILD_ID, DATABASE_PATH, MOD_LOG_CHANNEL_ID) are staged but have not been applied yet. You should see a "5 changes" bar at the top of the project canvas with a Deploy button. Click Deploy to apply the variables, and your next deployment will have them injected at runtime. Once applied, reply here and we can verify they are picked up.


Status changed to Awaiting User Response Railway 19 days ago


Status changed to Solved usmcrobloxwinro-droid 19 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...