14 days ago
Service returns 502 with x-railway-fallback: true despite app
running correctly on port 3000 in EU West region.
Pinned Solution
14 days ago
Yeah, I think I found your problem. Railway automatically injects the PORT variable into your container (in this case it's most likely 8080). Just map your URL to 8080, and it should fix your problem.
If it's not 8080 however, console log it, and see what value it is, then map it to your URL.
18 Replies
14 days ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open Railway • 14 days ago
14 days ago
can you be sure the exposed port is the same as the one in the network settings? Usually is 8080, you can check opening the service settings: Networking => Public network => Edit => Port
fra
can you be sure the exposed port is the same as the one in the network settings? Usually is 8080, you can check opening the service settings: Networking => Public network => Edit => Port
14 days ago
It is there. I'd made an attempt of using 3000, but surely I could use 8080 in case that makes a difference. Is it projected to make a difference? Also I see the Application logs in railway's UI. I suspect it's a reverse proxy of some sort inside of Railways's internals which is crashing the response somewhere for external HTTP calls.
thebestori
It is there. I'd made an attempt of using 3000, but surely I could use 8080 in case that makes a difference. Is it projected to make a difference? Also I see the Application logs in railway's UI. I suspect it's a reverse proxy of some sort inside of Railways's internals which is crashing the response somewhere for external HTTP calls.
14 days ago
If your app is listening on port 3000, your URL should be mapped to 3000 as well.
14 days ago
It is.
darseen
If your app is listening on port 3000, your URL should be mapped to 3000 as well.
14 days ago
It is.
thebestori
It is there. I'd made an attempt of using 3000, but surely I could use 8080 in case that makes a difference. Is it projected to make a difference? Also I see the Application logs in railway's UI. I suspect it's a reverse proxy of some sort inside of Railways's internals which is crashing the response somewhere for external HTTP calls.
14 days ago
the important is that the port in the settings matches the port exposed in your app, you can keep 3000 or use 8080 but they must match
fra
the important is that the port in the settings matches the port exposed in your app, you can keep 3000 or use 8080 but they must match
14 days ago
They match 1000%.
14 days ago
can you check is the app is exposed with this host? 0.0.0.0 if not try to use this one
fra
can you check is the app is exposed with this host? 0.0.0.0 if not try to use this one
14 days ago
App is exposed with 0.0.0.0
14 days ago
And I assume you're accessing your URL without appending :3000 at the end, right? Can you share more info about your setup? Relevant code snippets perhaps.
14 days ago
are you using a custom domain or the auto generated url?
fra
are you using a custom domain or the auto generated url?
14 days ago
The auto generated URL.
darseen
And I assume you're accessing your URL without appending `:3000` at the end, right? Can you share more info about your setup? Relevant code snippets perhaps.
14 days ago
It's a highly standard, auto Railway-generated URL. External access id done via standard port 80. Internally, the App runs on port 3000. Would gladly share additional info.
thebestori
It's a highly standard, auto Railway-generated URL. External access id done via standard port 80\. Internally, the App runs on port 3000\. Would gladly share additional info.
14 days ago
What tech stack are you using? Sharing your network config in your code is helpful. A screenshot of your networking section in your service settings (if you don't mind exposing the public URL). Usage of the PORT variable, and relevant logs, if any.
darseen
What tech stack are you using? Sharing your network config in your code is helpful. A screenshot of your networking section in your service settings (if you don't mind exposing the public URL). Usage of the `PORT` variable, and relevant logs, if any.
14 days ago
Sure. Gladly. Thank you for assisting, highly appreciated.
PORT in env. variables is 3000.
Networking section relevant part screenshot is attached.
I believe the most relevant app start part (NestJS) is:
await app.listen(parseInt(process.env.PORT || '3000'), '0.0.0.0');
Is this enough or should additional info be helpful?
Thank you!
Attachments
thebestori
Sure. Gladly. Thank you for assisting, highly appreciated. PORT in env. variables is 3000. Networking section relevant part screenshot is attached. I believe the most relevant app start part (NestJS) is: ```typescript await app.listen(parseInt(process.env.PORT || '3000'), '0.0.0.0'); ``` Is this enough or should additional info be helpful? Thank you!
14 days ago
Yeah, I think I found your problem. Railway automatically injects the PORT variable into your container (in this case it's most likely 8080). Just map your URL to 8080, and it should fix your problem.
If it's not 8080 however, console log it, and see what value it is, then map it to your URL.
14 days ago
That's a good thought! Will give it a try and report the results shortly.
darseen
Yeah, I think I found your problem. Railway automatically injects the PORT variable into your container (in this case it's most likely 8080). Just map your URL to 8080, and it should fix your problem. If it's not 8080 however, console log it, and see what value it is, then map it to your URL.
14 days ago
I can confirm it is now fully working. Thank you - and to ALL of those who responded! Much love and appreciation!
Status changed to Solved brody • 14 days ago
