FastAPI 502 after successful startup - tried everything
kalulolo
HOBBYOP

6 months 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

6 months ago

Can you share your deployment logs and the GitHub URL?


6 months ago


6 months ago

Cheater.


6 months ago

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


6 months ago

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


6 months ago

Not my first rodeo.


kalulolo
HOBBYOP

6 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 6 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...