App sleeping returns 502 Bad Gateway when the app is being resumed

After that error occurs, when I refresh the page again the app responds normally and there is nothing in logs. I have the new runtime enabled and the new proxy.

34 Replies

N/A


I would expect it to wait for the container to start up again and then display the page instead of just responding with a bad gateway


while the container is still being started


2 years ago

I assume that means the container did start but your app didn't respond in time


2 years ago

do you run migrations in your start command?


I do not


2 years ago

what kind of app is this?


nextjs site


which is not connected to any database or anything


just a static website


2 years ago

what's your start command?


Before the app starts railway responds


did not change it


not using custom


so its most likely just npm run start


2 years ago

are you using a health check


i am not


2 years ago

go ahead and implement that


just putting a / will work?


2 years ago

if it's a static site, yeah just the root path is fine


2 years ago

I can't remember if railway checks the health check when resuming a slept app, but it's good to have either way


Yeah it doesnt work


Before Starting Container appears in logs railway responds with a 502


i mean at the same time^


2 years ago

okay, i asked the team about this and will get back to you when i have more information


Thanks


2 years ago

did you need an immediate solution? because i may have something you can try



I will just disable app sleeping in the meantime Lol


2 years ago

sounds good!


2 years ago

got an answer back, this basically means your app was not able to answer the initial http request fast enough.

when there is an incoming request for a slept service, the sleeping service is started and is tcp probed every 30ms for a maximum of 10 seconds, once a prob is successful the http request gets sent to your app, if you app doesn't respond then you will see a railway error page


2 years ago

you have a few options -

  • figure out why your app accepts a tcp connection but not an http request and remedy that.

  • stick caddy in front of the service to retry connections on non-200 status code responses.

  • keep app sleeping disabled.


a year 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.


a year ago

cc @Bartek


Loading...