Service Variables added to my backend but dont load on deployment
tac42
FREEOP

4 months ago

Environment Variables Not Being Injected

Issue

Two environment variables (RESEND_API_KEY and FRONTEND_URL) are configured in the Railway Variables tab but are NOT being injected into the production environment at runtime.

Evidence

Added debug logging to server startup:

console.log('RESEND_API_KEY exists:', !!process.env.RESEND_API_KEY);
console.log('FRONTEND_URL:', process.env.FRONTEND_URL);

Deploy log output:

RESEND_API_KEY exists: false
RESEND_API_KEY value: undefined
FRONTEND_URL: undefined

What's Working

Other variables ARE injecting correctly:

  • JWT_SECRETwhite_check_mark emoji

  • DATABASE_URIwhite_check_mark emoji

  • FROM_EMAILwhite_check_mark emoji

  • RECAPTCHA_SECRETwhite_check_mark emoji

  • PORTwhite_check_mark emoji

  • NODE_ENVwhite_check_mark emoji

Expected: 9 variables | Actually injected: 7 variables

What We've Tried

  • white_check_mark emoji Added variables via Variables UI

  • white_check_mark emoji Verified names and values are correct

  • white_check_mark emoji Multiple manual redeployments

  • white_check_mark emoji Removed dotenv from production code

  • white_check_mark emoji Tried as both service and shared variables

Why are some variables injected but not these two specific ones?

Solved$10 Bounty

Pinned Solution

4 months ago

Hey, you have click on the deploy button to apply the changes. Please check the attached video.

Attachments

7 Replies

Railway
BOT

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


4 months ago

Hey, can you show how your service's variable tab looks like? Service variables are applied correctly if they aren't showing a purple background. You haven't applied them, if they still show a purple background, I have attached a screenshot to illustrate what I have just said.

In the screenshot above, the FOO service variable has not yet been applied and can be applied by deploying it via the Deploy button.

Attachments


tac42
FREEOP

4 months ago


i've deployed many times after adding these vars. then removed them and added them again and deployed again but its always purple and look at the second screenshot showing deployment missing them.


tac42

i've deployed many times after adding these vars. then removed them and added them again and deployed again but its always purple and look at the second screenshot showing deployment missing them.

4 months ago

Hey, you have click on the deploy button to apply the changes. Please check the attached video.

Attachments


4 months ago

Hey, did you manage to solve the issue?


tac42
FREEOP

4 months ago

yes honestly it was as simple as your video but i swear i didn't see the button until you pointed it out. and what is the difference of deploying from the main setting VS. the variable tab. maybe a new variables should be pushed when you deploy from the regular button and or the git push. but that's just a suggestion because i don't really care at this point so long as my website works.

Thank you!


tac42

yes honestly it was as simple as your video but i swear i didn't see the button until you pointed it out. and what is the difference of deploying from the main setting VS. the variable tab. maybe a new variables should be pushed when you deploy from the regular button and or the git push. but that's just a suggestion because i don't really care at this point so long as my website works.Thank you!

4 months ago

You are welcome! The main idea is that you will need to approve the changes you have made or discard them, that is why you have explicitly approve/deploy the changes you have made. It would also be inefficient if it just deployed a single change instantly, imagine wanting to define 10 variables and all of them triggering a new deployment while your app is screaming that it is still missing the other ones you haven't defined.


Status changed to Solved uxuz 4 months ago


Loading...