Service Variables not available in Node.js app / process.env returns undefined

recompany9401
HOBBY

2 months ago

Hello,
I'm experiencing a persistent problem where all Service Variables defined in my Railway service are not available to my Node.js application (process.env).
Even when I add a new variable (e.g. DEMO_VAR) directly to the Service Variables (not Shared Variables), it still shows as undefined in my app.

Here is what I have tried:

  • Deleted and recreated the service from scratch.

  • Entered variables directly in the Service Variables (not using shared references).

  • Used the Raw Editor to double-check the variable names and values.

  • Fully redeployed/restarted the service after any change.

  • Printed out the entire process.env in my code; only system/default Railway variables show up, but none of my custom variables (ADMIN_USERNAME, ADMIN_PASSWORD, DEMO_VAR, etc).

  • Minimal test variable like DEMO_VAR=hello is still undefined.

Solved

5 Replies

chandrika
EMPLOYEE

2 months ago

Hi there, can you link to the service you are having this issue with? Is this only happening in that one project and only in Node and working with other services / applications?


Status changed to Awaiting User Response Railway 2 months ago


muratyildirim24
FREE

2 months ago

hi
i also have the same situation
i can not access variables from node.js with process.env
code returns "undefined"

can you help ?


Status changed to Awaiting Railway Response Railway 2 months ago


chandrika

Hi there, can you link to the service you are having this issue with? Is this only happening in that one project and only in Node and working with other services / applications?

recompany9401
HOBBY

2 months ago

Hi,

I just checked and the environment variables work perfectly on my other project (“glorious-learning” / fair-project-backend-production.up.railway.app).

The problem only happens with my project “supportive-tenderness” (koad-backend-production.up.railway.app), where all custom environment variables are undefined in my Node.js app, despite using the same process as my other project.

Please help me find out why variables don’t work on this project!

Thank you.


muratyildirim24
FREE

2 months ago

i recreated the same project with builder: Railpack finally i can access the variables


muratyildirim24

i recreated the same project with builder: Railpack finally i can access the variables

parmstar
EMPLOYEE

2 months ago

wonderful! Good to know. Thanks!


Status changed to Awaiting User Response Railway 2 months ago


Railway
BOT

a month 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 29 days ago


Service Variables not available in Node.js app / process.env returns undefined - Railway Help Station