Railway deployment shows 502 on all routes for Next.js 16 standalone even though container is Ready on port 8080
devhusnain
PROOP

a month ago

Hi everyone, I need help debugging a Railway deployment issue.

I am deploying a Next.js 16.1.6 app with standalone output.

Container logs show the app starts successfully and is ready:

Next.js 16.1.6

Local/Network: http://container-id:8080

Starting...

Ready in ~50ms

But the Railway public domain returns 502 for all routes, including:

/

/favicon.ico

/sw.js

/api/notifications/stream

What I already configured:

Standalone start command: node server.js

Build includes copying .next/static and public into .next/standalone

AUTH_PROXY_TARGET env variable is set

Also tested generated Railway domain (not only custom domain), still 502

One thing I noticed:

Start phase still appears to run corepack/yarn preparation in logs, so I am not sure if Railway is using my exact start command or an old/cached deploy plan.

Questions:

Why would Railway return 502 for every route when the app is clearly Ready on 8080?

Could this be an ingress/domain mapping issue rather than app runtime?

Best way to force Railway to use only:

Custom Build: npm i -g corepack@latest && corepack enable && corepack prepare yarn@4.13.0 --activate && yarn install --immutable && yarn build

Custom Start: npm i -g corepack@latest && corepack enable && corepack prepare yarn@4.13.0 --activate && yarn start

Any recommended way to fully clear build/runtime cache and domain routing state?

Any guidance on where to check next in Railway would be appreciated.

Solved$20 Bounty

2 Replies

Status changed to Open Railway 28 days ago


Something I'd try is to explicitly make your Next application listen on an arbitrary port (eg, 3000), and map the URL to port 3000 as well. See if that works.


devhusnain
PROOP

a month ago

Custom docker setup fixed the issue.


Status changed to Solved Railway 28 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...