502 Bad Request error occurring when waking up the service after App Sleep

sam-mahonriTRIAL

9 months ago

In this case, the 502 Bad Request error occurs only when the service is waking up from App sleep. There's no cold start; it doesn't wait and immediately returns a 502 error. After about 2 to 5 seconds, refreshing the page resolves the issue, but this problem only happens during the application's wake-up process. The issue doesn't occur when the service is already awake. What could cause Railway to return a 502 when it should be just a cold start? I'm developing a project in Next.js with a custom server, as described in Railway's documentation, and it's being used under the Cloudflare Proxy. Is there a way to resolve this issue or at least increase Railway/Cloudflare's timeout to wait for the service to wake up?
id: cf4394a0-0027-4329-a43a-0df88b77c287

0 Replies

9 months ago

this is a known issue, and its something they want to fix.


sam-mahonriTRIAL

9 months ago

I noticed that this doesn't happen with other services. I'm running a Python Flask service in the same project, and it wakes up from app sleep without any issues. It seems to be something specific to Node or something related to the custom server.


9 months ago

not too sure what you mean by custom server



9 months ago

curious as to why you need a custom server for railway specifically?


sam-mahonriTRIAL

9 months ago

This is the only way to run Socket.IO in a single service in the Next.js app router. Of course, it would be better to create a separate service, so I noticed this issue. But again, I'm not sure if this is the problem.


9 months ago

gotcha, but yeah this is an issue with railway, and they are aware


5 months ago

We've resolved an issue where apps with longer startup times were showing 502 errors. Apps now have up to 10 seconds to start accepting traffic, thus preventing these error pages from appearing.

You will need to trigger a deployment so that the changes we have made take effect.


5 months ago

cc @Sam 🤍