Fly.io 502 Bad Gateway
Quick answer
A 502 means the Fly proxy reached your Machine but the app crashed or answered wrongly. Check fly logs, the listen port, health check grace period and OOM kills.
Most likely fix: Read the logs
How to fix it
Try these in order — the most common fix is first.
1. Read the logs
- Run fly logs while reproducing the request
- Look for stack traces or exit codes
Did this fix it?2. Increase the grace period if it happens right after deploy
- Add or raise grace_period on your health check (start at 10s; Rails, Django and big JVM apps may need 15 to 30s)
- Run fly deploy
Did this fix it?3. Rule out OOM for intermittent 502s
- Run fly machine status <machine-id>
- Inspect memory in fly ssh console with free or htop
- Run fly scale memory 512 or larger
Did this fix it?
Symptoms
Browser or curl returns 502 Bad Gateway, either right after a deploy or intermittently.
Why it happens
- App crashes mid-request
- Wrong listen port
- App not ready after deploy
- Machine killed for running out of memory
This guide also covers
- fly.io 502 bad gateway
- fly.io 502 after deploy
- fly.io intermittent 502
Still not working?
If Fly.io keeps failing, you're not alone. See every Fly.io problem users report or the alternatives people switch to.
Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.
Talk to usOther Fly.io errors
- Fly.io: The app is not listening on the expected address and will not be reachable by fly-proxy
- Fly.io 503 Service Unavailable
- Fly.io Health Checks Failing
- Fly.io Machines Stopping or Not Starting (Auto-Stop)
- Fly.io Out of Memory (OOM Killed)
- Fly.io Deploy Failed: Waiting for Depot Builder, Registry 401, Too Many Requests
- Fly.io Certificate Not Issuing or Custom Domain Not Working
- How to Cancel Fly.io: Delete an App, Stop Billing and Delete Your Account