502 Bad Gateway — "Application failed to respond" on sleeping Next.js app wake-up
dijiflex
HOBBYOP

3 months ago

Starting approximately 2 days ago (around March 6, 2026), all my Next.js services are returning "Application failed to respond" (502 Bad

Gateway) on the first request after the app has been sleeping. Refreshing the page immediately after resolves the issue — the app loads

fine once awake.

Key details:

- Framework: Next.js 16 (App Router, standalone output mode)

- Affected services: 3 Next.js apps (home, client, admin) across both staging and production environments (6 services total)

- All services have sleep enabled

- No deployments to production in over a month — this rules out a code change on my end

- Staging has had recent deploys, but the same issue also appears on production with no code changes

- Behavior: First request after sleep → 502. Manual refresh → works fine. This is consistent and reproducible across all 6 services.

- Started: ~2 days ago. Before that, sleeping apps woke up without any 502 errors.

- Request ID (example): X5dEd7jNS3uwNtjNw9P4nw

What I suspect:

Next.js standalone server takes a few seconds to cold-start. It seems like Railway's proxy is now returning a 502 before the Next.js

server finishes booting — rather than waiting for it as it did previously. This may be related to a change in proxy timeout or sleep

wake-up handling, or possibly a change in how Railway handles Next.js apps specifically.

What I've ruled out:

- No code or config changes on production

- All 6 services (3 apps x 2 environments) exhibit the same behavior simultaneously

- Apps work perfectly once awake — no errors in deploy logs

- Not app-specific — affects home (marketing), client, and admin apps equally

Could the Railway team check if there was a recent infrastructure change affecting sleep wake-up timeouts, proxy behavior, or

Next.js-specific handling? Thanks!

Attachments

Solved

9 Replies

Status changed to Awaiting Railway Response Railway 3 months ago


sam-a
EMPLOYEE

2 months ago

Hey, thanks for the detailed report. Your suspicion is correct.

We've identified a bug in how the serverless wake-up flow handles the initial request. The proxy can return a 502 before the container has fully booted and is ready to accept traffic. This is a platform-side issue, not anything on your end. We're tracking it internally and working on a fix.

Workaround: You can temporarily disable the Serverless setting on the affected services (Settings > Networking > Serverless). This keeps services running continuously and eliminates the 502 on wake-up. You can re-enable it once we've shipped the fix.

We'll update this thread when it's resolved.


Status changed to Awaiting User Response Railway 2 months ago


dijiflex
HOBBYOP

2 months ago

Thank you


Status changed to Awaiting Railway Response Railway 2 months ago


Status changed to Awaiting User Response sam-a 2 months ago


Railway
BOT

2 months ago

Hello!

We've escalated your issue to our engineering team.

We aim to provide an update within 1 business day.

Please reply to this thread if you have any questions!


mattijsdp
PRO

2 months ago

Watching this thread as I'm also experiencing this


Status changed to Awaiting Railway Response Railway 2 months ago


chandrika
EMPLOYEE

2 months ago

Quick update, we're reproduced the issue and our platform team will be looking into a fix for this. Thank you all for your patience, will keep you posted


Status changed to Awaiting User Response Railway 2 months ago


2 months ago

Our platform team was able to push out a fix, let us know if you still run into this!


nico

Our platform team was able to push out a fix, let us know if you still run into this!

dijiflex
HOBBYOP

2 months ago

I just tested. Not yet resolved


Status changed to Awaiting Railway Response Railway 2 months ago


2 months ago

A redeploy is required for the new changes to take effect.


Status changed to Awaiting User Response Railway 2 months ago


jtela-finres
PRO

2 months ago

Hello OP,

I also did encounter the issue with my nextjs app on a sleeping service.

I did 2 things :

- fix the error saying that it couldn't find the favicon.ico (I placed it at the root of the app directory). It was the only issue I can saw in the console when I hit the HTTP 502.

- redeploy my service to be sure I have the fix provided by the railway team

Now my service behaves like before.

Hope it helps.

Cheers !


Status changed to Awaiting Railway Response Railway 2 months ago


Status changed to Solved brody 2 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...