502 Bad Gateway: When One Server Gets a Bad Reply
A 502 Bad Gateway means an upstream server gave an invalid response, a common outage signal across hosting setups.
502 Bad Gateway is the status code when an upstream server replies badly.
What It Is
A 502 Bad Gateway means a gateway or proxy got an invalid response upstream.
The server in front could not get a valid reply.
It is usually a network or backend problem.
Why It Matters
- It takes the site down for visitors.
- Crawlers record the outage and back off.
- Long 502s hurt crawl behavior.
- It can follow scaling or config changes.
- Quick response limits the damage.
How to Do It
- Check the proxy and load balancer logs.
- Verify the backend service is alive.
- Review recent config and deploy changes.
- Restart the gateway or backend carefully.
- Monitor status code rates during traffic spikes.
What to Avoid
- Hiding the error behind a cached page forever.
- Restarting backends without checking health.
- Ignoring recurring 502 patterns.
- Serving 502 to crawlers for days.
- Letting one service take the whole site down.
Common Mistakes
- A backend crash under load.
- A proxy timeout set too low.
- Bad health-check configuration.
- DNS pointing at a dead server.
- No alerting on 502 spikes.
Before: the site returns 502 after a traffic spike.
After: a backend service crashed under load.
The result: scaling and health checks stop the pattern.
The lesson: the front server was fine; the backend failed.
Quick Tip
Keep health checks honest so a failing backend gets drained before it takes the gateway down.
Frequently Asked Questions
502 Bad Gateway, in Short
A gateway is only as healthy as its upstream.
Fix the backend and the 502 disappears.
Good health checks prevent the pattern.