Fly.io 502 Bad Gateway

Share
Ongoing Fly.io Updated November 14, 2026How we research

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. 1. Read the logs

    1. Run fly logs while reproducing the request
    2. Look for stack traces or exit codes
    Did this fix it?
  2. 2. Increase the grace period if it happens right after deploy

    1. Add or raise grace_period on your health check (start at 10s; Rails, Django and big JVM apps may need 15 to 30s)
    2. Run fly deploy
    Did this fix it?
  3. 3. Rule out OOM for intermittent 502s

    1. Run fly machine status <machine-id>
    2. Inspect memory in fly ssh console with free or htop
    3. 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 us
Fixed it? Share this guide

Other Fly.io errors