FastAPI 502 after successful startup - tried everything
kalulolo
HOBBYOP

19 days 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

Can you share your deployment logs and the GitHub URL?


brody
EMPLOYEE

19 days ago



brody
EMPLOYEE

19 days ago

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


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


brody
EMPLOYEE

19 days ago

Not my first rodeo.


kalulolo
HOBBYOP

18 days 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 18 days ago


Loading...