How to Fix a 502 Bad Gateway Error — cPanel & Hosting How-Tos cPanel & Hosting How-Tos

How to Fix a 502 Bad Gateway Error

By Genhost Team 2 min read

A 502 Bad Gateway error means one server got an invalid or no response from another process behind it — most often PHP timing out, crashing or being overwhelmed. It’s usually temporary, but repeated 502s point to something you can fix.

What causes a 502

  • PHP overloaded or crashing — too many requests at once, or a script that dies mid-run.
  • A slow script or query that doesn’t respond in time.
  • Hitting resource limits — CPU or entry processes maxed out during a spike.
  • A heavy or buggy plugin generating a bad response.
  • A brief server-side hiccup — in which case it clears on its own.

How to fix it

1. Reload and wait a moment

A single 502 is often transient. Refresh after 30–60 seconds. If it clears and doesn’t return, it was a brief spike — nothing to fix.

2. Clear your cache

Server and browser caches can keep showing a stale 502. Clear your browser cache and, if you use LiteSpeed/CDN caching, purge it — see clear your cache when changes don’t show.

3. Check your resource usage

Repeated 502s during busy periods usually mean your account is hitting CPU or entry process limits. Open Resource Usage in cPanel and check the faults list — see understand your resource usage, the CPU limit guide and the entry processes guide.

4. Speed up PHP so it responds in time

5. Test for a bad plugin or theme (WordPress)

Deactivate plugins (rename wp-content/plugins in File Manager if you can’t log in) to see if a faulty one is causing the bad response. See common WordPress errors.

Still getting 502s?

If 502s persist after caching and optimizing, your site may have outgrown shared resources. A Managed VPS gives you dedicated CPU and PHP capacity. Our site-down troubleshooting guide and support team can help confirm the cause.

Every Web Hosting and WordPress Hosting plan at Genhost shows your resource usage clearly, so you can see exactly what’s behind a recurring 502.

Frequently asked questions

What does a 502 Bad Gateway error mean?

It means a server handling your request got an invalid response from another server or process behind it — often PHP timing out, crashing, or being overwhelmed. It's usually temporary and clears when the load drops or the process restarts.

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

It can be either. A one-off 502 during a traffic spike is usually transient. Repeated 502s often point to a slow or crashing script, a heavy plugin, or hitting resource limits on your account — all of which you can address.

How do I stop 502 errors from coming back?

Enable full-page caching, use a modern PHP version, remove heavy plugins, and fix slow database queries so PHP responds quickly. If your account keeps hitting resource limits, consider upgrading.