502 critical
502 Bad Gateway
A 502 means one server got an invalid response from another upstream server. The fix depends on which link in the chain failed.
What you see
HTTP 502 — Bad Gateway The proxy server received an invalid response from an upstream server.
What’s actually happening
Your site sits behind a gateway or proxy (a CDN, load balancer, or Nginx in front of PHP-FPM). The gateway tried to fetch your page from the backend and got garbage or no response back. Often intermittent, which makes it maddening.
Common causes
- The backend application (PHP-FPM, Node, etc.) crashed or is overloaded
- A CDN/proxy (Cloudflare, Nginx) can’t reach the origin server
- A firewall is blocking the connection between proxy and origin
- The origin took too long and the gateway gave up
How to fix it
- Check the origin server directlyBypass the CDN and hit the origin IP. If the origin is also down, the problem is your server, not the gateway — restart the backend service (php-fpm, node, etc.).
- Restart the backend processA crashed or hung application worker is the most common cause. Restart PHP-FPM / your Node process / the app container and watch whether the 502 clears.
- Look at the proxy + origin logs togetherThe Nginx/CDN log shows the failed upstream; the origin log shows why. Match the timestamps to find the failing request.
- Rule out CDN or firewall blocksIf you use Cloudflare, check that the origin isn’t blocking Cloudflare’s IPs and that SSL mode (Full/Flexible) matches your origin’s setup.
Stop it recurring
Add health checks and auto-restart to backend processes, and set sane timeouts so a slow request degrades instead of cascading into 502s.
Related errors