6 months ago
I am experiencing a 502 Bad gateway error, I understand what this error is but I don't know how to fix it.
the coding:
app.enableCors(CORS);
const port = process.env.PORT || 3001;
await app.listen(port, '0.0.0.0');
I understand that railway gives me a port by default so this should be enough
9 Replies
6 months ago
Your code is fine, so please read this section - https://docs.railway.app/guides/fixing-common-errors#application-failed-to-respond
You can skip to the part about target ports.
6 months ago
Sorry, but from what I see in that documentation, my API should work correctly
It should be noted that for the API I am using port 44855
\
6 months ago
I still can't find the problem, the only thing I can see in the docs that might be the issue is the Target Ports issue but it clearly told me that I can skip it.
6 months ago
I said skip to the target port section, not to skip over it, please re-read my initial message.
6 months ago
Hi all,
I encountered same issue with my NestJS API today.
All is running well after deploys, and get worse after a period of inactivity.
After investigation, i think it's the App Sleeping causing this issue, for now i deactivated it on my production environment, but it will cost more i guess if the service stay alive 24/24 ? If so, it would be embarrassing.
6 months ago
Okay understood !
On the other hand i did it on development environment, what is the process to wake this service up correctly without this annoying 502, which visibly remains after waking up ?
6 months ago
The 502 only happens when your app does not start fast enough, we have something in the works for apps that don't start fast enough.
Please subscribe to the linked thread to be notified when we have a fix live for that.
https://help.railway.app/questions/v2-app-sleep-first-response-always-e-e4fb96c7
Status changed to Closed brody • 6 months ago