Spring Fresh Sale! - Up To 67% OFF BDIX Hosting + Free Domain
Troubleshooting

How to Fix the “502 Bad Gateway” Error

A "502 Bad Gateway" error means one server, acting as a gateway, received an invalid response from another server it relied on. On web hosting this usually points to the PHP handler, a proxy, or a service that briefly failed to respond — often something temporary rather than a broken website.

Try the simple things first

  • Reload the page — many 502s are momentary and clear on their own.
  • Clear your browser cache, or try a private window, to rule out a cached error.
  • Wait a minute — if a background service was restarting, it may already be back.

Common causes on shared hosting

  • A PHP process that timed out or crashed, often under heavy load. Check whether you are hitting limits — see resource limit errors.
  • A slow or stuck script that never returned a response.
  • A CDN or proxy in front of your site (like Cloudflare) reporting the origin as unreachable.

If you use Cloudflare

When Cloudflare shows a 502, the issue is usually your origin server not responding in time. Pause Cloudflare briefly (DNS-only mode) and test the site directly; if it loads, the origin recovered and you can re-enable the proxy. Our guide on Cloudflare covers the basics.

Dig into the cause

Read your error log for clues, and check your resource usage to see if a load spike lined up with the error. Heavy, unoptimised sites hit 502s more often, so caching genuinely helps.

Frequently asked questions

Is a 502 error my fault or the server's?

It can be either, but on shared hosting it is frequently a script or plugin that overloaded or stalled a PHP process. If the error is constant rather than occasional, investigate your site before assuming a server fault.

It keeps coming back every few minutes.

A repeating 502 suggests a recurring overload — a heavy cron job, a runaway plugin, or genuinely outgrowing your plan. Check resource usage, add caching, and if it persists, consider more resources.

Nothing I try works.

If the site stays down and logs point to a server service, it is time for us to look. Open a support ticket with the time the error started and any log entries.

Was this article helpful?