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.
Solution:Jump to solution
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....
21 Replies
Project ID:
N/A
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
I assume that means the container did start but your app didn't respond in time
do you run migrations in your start command?
I do not
what kind of app is this?
nextjs site
which is not connected to any database or anything
just a static website
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
are you using a health check
i am not
go ahead and implement that
just putting a
/
will work?if it's a static site, yeah just the root path is fine
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^okay, i asked the team about this and will get back to you when i have more information
Thanks
did you need an immediate solution? because i may have something you can try
No
I will just disable app sleeping in the meantime Lol
sounds good!
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
Solution
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.
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.
cc @Bartek