a month ago
Hi Railway team,
My deployed FastAPI backend is consistently showing:
"Application failed to respond"
HTTP 502 Bad Gateway (from Railway edge)
Healthcheck failures on /api/health
But internally, the application logs show:
Uvicorn starts successfully
"Application startup complete"
No crashes or stack traces
/api/health returns 200 OK when hit directly (sometimes via curl)
---
# π Environment Details
- Platform: Railway
- Region: asia-southeast1-eqsg3a
- Framework: FastAPI (uvicorn)
- Start command:
uvicorn app.main:app --host 0.0.0.0 --port $PORT --workers 1 --proxy-headers --forwarded-allow-ips "*"
- Healthcheck path: /api/health
- Deployment type: Nixpacks
---
# π¨ Problem Summary
1. Railway dashboard shows:
"Application failed to respond"
2. External requests sometimes fail with:
HTTP 502 Bad Gateway
{"message":"Application failed to respond"}
3. However:
- Container is running
- Uvicorn is bound to 0.0.0.0:$PORT correctly
- Startup logs show no crash
- Health endpoint works intermittently via curl
4. Example curl response:
- TLS OK
- Connection OK
- But Railway edge returns 502 intermittently
---
# π What I already verified
PORT is correctly using Railway's $PORT (not hardcoded)
Only 1 worker (workers=1)
/api/health is lightweight and returns static JSON
No blocking code in startup
No DB dependency in healthcheck
MongoDB / Redis failures do NOT crash startup
---
# β What seems broken
This appears to be a Railway edge routing / proxy issue, not an application crash.
Symptoms suggest:
- requests reach Railway edge
- but fail to properly route to running container OR timeout at edge layer
- intermittent 502 even when container is healthy
---
# β Request
Please help investigate:
1. Is there any known issue with:
- asia-southeast1-eqsg3a region routing
- edge proxy instability
- healthcheck misconfiguration
2. Can you confirm:
- whether traffic is reaching my container
- or failing at Railway edge before container
3. Any recommended fixes for:
- intermittent "Application failed to respond"
- 502 Bad Gateway despite healthy container
---
# π Additional info
- Same issue persists across redeploys
- Restart does not fix issue
- Curl sometimes works, sometimes returns 502
- No application-level errors seen in logs
---
Thanks β this looks like a platform-level routing/healthcheck issue rather than application bug.
1 Replies
Status changed to Open Railway β’ 28 days ago
a month ago
Just a shot in the dark here that will probably not fix your main issue, you said you're using Nixpacks which is deprecated.
If this is true, please change to Railpack which is the new builder.