502 error on custom domain
raiyansayeed
PROOP

2 months ago

Hi I have a frontend service connected to a custom domain and the deploy logs aren't showing any errors. But I keep getting 502 errors when trying to access the domain?

$10 Bounty

7 Replies

raiyansayeed
PROOP

2 months ago

Project ID: 5887a349-ee4c-49d0-b508-f978388f28c1
Service: frontend


raiyansayeed
PROOP

2 months ago

I assumed it was a lets encrypt issue since there was an outage yesterday but am still getting 502s even now with everything back up


raiyansayeed
PROOP

2 months ago


raiyansayeed
PROOP

2 months ago

tried switching to nixpacks builder, still not working


brody
EMPLOYEE

2 months ago

This is also not related to the Let's Encrypt outage. I am going to let the community help you debug this configuration or application-level issue.


domehane
FREE

2 months ago

first check if your railway domain itself works (like the frontend-production.up.railway.app one)if that works then it's definitely a custom domain ssl thing, if it doesn't then your app config is the problem

most common issue is the port binding. your app needs to listen on 0.0.0.0 not localhost, and it needs to use railway's PORT env variable. like this:

javascript

// this breaks everything
app.listen(3000, 'localhost');

// this actually works
const port = process.env.PORT || 3000;
app.listen(port, '0.0.0.0', () => {
  console.log(`listening on 0.0.0.0:${port}`);
});

check your deployment logs too ,you should see something like "server listening on 0.0.0.0:8080" or whatever port. if you see localhost or 127.0.0.1 that's your problem right there


raiyansayeed
PROOP

2 months ago

Thanks for the steps, ended up actually being an application error (I was running the 'dev' command to start instead of my production static files).


Loading...