Code: HTTP 502 Bad Gateway Web Browser Errors Est. Time: 3 mins Level: Easy

502 Bad Gateway The Server Received an Invalid Response

Understand and troubleshoot HTTP 502 Bad Gateway errors on visitors’ browsers and Cloudflare/Nginx origin servers cleanly without fruitless local resets.

Authored by SolveKits Team • Last updated:

Overview & Technical Context

HTTP status 502 Bad Gateway means an edge server or reverse proxy (such as Cloudflare, AWS ALB, or Nginx) tried forwarding your browser request onward to an internal backend server (php-fpm, Node app, or origin host) and received a mangled, empty, or rejected response back. Crucially, 502 almost always signals a server-side disconnect between two machines in the website’s infrastructure rather than broken home Wi-Fi. Still, stale cached site cookies, old Cloudflare/CDN edge state, or broken browser proxies occasionally cause localized 502 hiccups for visitors—while backend health checks, php-fpm worker checks, and SSL handshake fixes cure it permanently for site operators.

Specific Symptoms

  • Chrome loads a branded Cloudflare or plain white 502 Bad Gateway notice indicating the Host (Origin) failed while Browser and Cloudflare indicators show green.
  • Reloading (Ctrl + Shift + R) works intermittently as load balancers route between healthy and crashed backend servers.
  • Large admin dashboard submits or massive cookie jars trigger 502 solely on one signed-in browser.
  • (Site owners) Traffic spikes crash php-fpm/Node processes leaving Nginx reporting upstream prematurely closed connection.

Why This Error Occurs

  • The origin web app daemon (PHP-FPM, Gunicorn, Node.js) crashed or hit OOM memory limits behind Nginx/Cloudflare.
  • Edge reverse proxy and origin server disagree on TLS SSL protocols or firewall allowlisting.
  • Transient upstream cloud outages (AWS, Cloudflare, Fastly) drop gateway hops briefly.
  • For individual visitors: oversized corrupted session cookies or stale DNS/CDN cache lingers after a host migration.

Troubleshooting Steps

1

Wait 60 seconds, hard-refresh, and verify whether the site fails globally

Press Ctrl + Shift + R (Cmd + Shift + R on Mac) after waiting one minute—during rolling software deploys or quick worker restarts, 502 Bad Gateway clears right away on its own. Test loading the same URL in Incognito or on cellular data to confirm global host downtime vs local cache.

2

Clear cookies strictly for that site if Incognito succeeds

If Incognito works smoothly while your regular browser hangs on 502, click the padlock/tune controls beside the URL bar, clear cookies and site data strictly for that domain, and log back in cleanly—oversized SSO or session headers occasionally choke upstream proxy buffers into 502.

3

Pause suspicious browser extensions or corporate proxies temporarily

Double-check Settings → Network & internet → Proxy isn’t routing requests via a misbehaving local proxy, and check Cloudflare/host outage trackers if prominent sites report 502 simultaneously.

4

(Site Owners) Check upstream worker logs, OOM kills, and origin SSL

Administrators running Nginx/Cloudflare should inspect backend service uptime (php-fpm, gunicorn, pm2), scan dmesg / journal logs for Out-Of-Memory worker kills, confirm firewall rules permit edge CDN IPs cleanly on ports 80/443, and match origin TLS/buffer settings.

What to Check If the Issue Continues

If an important site stays stuck on 502 Bad Gateway past fifteen minutes globally on both PC and phone, step away and retry later—the site’s engineering team has to restart crashed origin processes or clear upstream firewall drops.

Frequently Asked Questions

What does Cloudflare’s "Browser: Working / Cloudflare: Working / Host: Error 502" diagram prove?

It proves cleanly that your home internet, browser, and Cloudflare CDN connected without errors, while Cloudflare failed connecting cleanly to the website’s own backend hosting server.

Can changing my PC DNS fix an HTTP 502 Bad Gateway?

Only in rare migrations where stale DNS pointed your ISP resolver at a retired server IP; running ipconfig /flushdns checks that fast, though 95%+ of 502 errors belong solely to the destination host.

How is 502 Bad Gateway different from 504 Gateway Timeout?

502 Bad Gateway happens when the upstream backend server responds immediately with broken/corrupt data or kills its socket early; 504 Gateway Timeout happens when the backend server never answers at all before the proxy deadline expires.

Can an overfilled server disk trigger 502 Bad Gateway?

Yes! On WordPress or database-driven VPS boxes, hitting 100% full disk stops php-fpm sockets, logs, and MySQL from starting properly behind Nginx, displaying 502 instantly.

Search Another Error or Symptom

Search all 292 guides and tools on SolveKits: