FastAPI 502 after successful startup - tried everything
kalulolo
HOBBYOP

a year ago

Deployment be929b7c returns 502 errors despite successful startup. Logs show Uvicorn running on 8080, but all requests fail with "x-railway-fallback: true".

Tested with minimal FastAPI app (2 endpoints only), no middleware, no health checks, both us-west1 and asia-southeast1 regions. Same result every time.

Similar to this solved thread but solution not documented:

https://station.railway.com/questions/app-deploys-successfully-but-returns-502-1cedac14

Anyone know what fixed it?

Solved$10 Bounty

7 Replies

a year ago

Can you share your deployment logs and the GitHub URL?


a year ago


a year ago

Cheater.


a year ago

Depends. I knew it was likely that issue, so I could have sent the link without looking.


a year ago

I don't like to assume <:sad_hamster:1280780987504267328>


a year ago

Not my first rodeo.


kalulolo
HOBBYOP

10 months ago

Thanks — that doc fixed it. I had Uvicorn starting on the wrong port/host. I changed my start command to:

```uvicorn main:app --host 0.0.0.0 --port ${PORT:-8080}````

and updated the Railway service target port to 8080. After redeploy the edge returns 200. Logs now show Uvicorn listening on 0.0.0.0:8080. Appreciate the pointer — saved me a lot of time.


Status changed to Solved brody • 11 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...