I keep getting a 502 respone
rmzhaddad
FREEOP

2 months ago

I have successfully deployed a .netcore api project but once I try to hit a endpoint, i keep getting 502 and there is no log errors, only 502 response, 6 hours trying to deal with this, any idea

Solved

5 Replies

Railway
BOT

2 months ago

A 502 error means our edge proxy can't reach your application. For .NET Core apps, the most common cause is that the app is not listening on 0.0.0.0 using the PORT environment variable that we inject automatically. Your app must bind to 0.0.0.0:$PORT (not localhost, not a hardcoded port). You can find more details in our troubleshooting guide.


Status changed to Awaiting User Response Railway about 2 months ago


rmzhaddad
FREEOP

2 months ago

I added this to the program.cs

var port = Environment.GetEnvironmentVariable("PORT");

if (!string.IsNullOrWhiteSpace(port))

{

builder.WebHost.UseUrls($"http://0.0.0.0:{port}");

}


Status changed to Awaiting Railway Response Railway about 2 months ago


rmzhaddad
FREEOP

2 months ago

still didnt work


Railway
BOT

2 months ago

Your app is listening on port 8080 rather than the Railway-provided PORT variable, which means our proxy can't reach it. You can fix this by either redeploying with your updated code that reads $PORT (it doesn't appear to have taken effect yet), or by setting a target port of 8080 on your domain in the service settings.


Status changed to Awaiting User Response Railway about 2 months ago


rmzhaddad
FREEOP

2 months ago

it finally worked, You are the sun for the dark days and the rain for the dry land


Status changed to Awaiting Railway Response Railway about 2 months ago


Status changed to Solved Railway about 2 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...