# How to Fix HTTP Error 502 (Bad Gateway)

> Canonical: https://jethost.com/kb/how-to-fix-http-error-502-bad-gateway/ · Last modified: 2026-10-31T13:35:33+00:00

HTTP Error 502 – “Bad Gateway” – means one server, acting as a gateway, got an invalid reply from another server behind it. The page didn’t load because the hand-off failed. It is usually temporary and caused by server load, a crashed PHP process, or a CDN like Cloudflare. Here is how to clear it.

## What the error means

Many sites sit behind a gateway – a proxy, a CDN, or a web server passing requests to PHP. A 502 appears when that gateway asks the server behind it for the page and gets a broken or empty answer. The front door is fine; the room behind it didn’t respond properly.

## If you are just visiting

1. Reload the page – a 502 is often a brief hiccup that clears on its own.
2. Clear your browser cache, and [flush your DNS cache](https://jethost.com/kb/how-to-flush-dns-cache-on-windows-mac-and-linux/).
3. Try again in a few minutes. If it persists for everyone, it is on the website.

## If the website is yours

1. Check your error log for the real cause – see [how to find and fix PHP errors](https://jethost.com/kb/how-to-find-and-fix-php-errors-logs-and-debugging/).
2. Rule out overload. A spike in traffic or a heavy plugin can crash the PHP process behind the gateway. Pause a suspect plugin and watch.
3. Check your CDN. If you use Cloudflare, a 502 can mean it couldn’t reach your origin – pause it briefly to test whether the origin loads directly.
4. Give it a moment after a restart. If the server or PHP service just restarted, 502s can show for a few seconds until it is ready.

## On JetHost hosting

If a 502 keeps showing on a site you host with us, open a ticket and we’ll check the server and PHP processes. Repeated 502s under traffic often mean the site has outgrown its plan, and we can help you move up. Related errors: [HTTP 500](https://jethost.com/kb/how-to-fix-http-error-500-internal-server-error/) and [HTTP 504](https://jethost.com/kb/how-to-fix-http-error-504-gateway-timeout/).

## JetHost Experts Tip

If you use Cloudflare, test with it paused. A 502 that disappears when Cloudflare is off points at the CDN or the origin connection, not your site’s code.

## Frequently asked questions

**Is a 502 my fault?**Not always. It can be a brief server hiccup, a CDN issue, or a crashed process under load. If it clears on reload, it was temporary.

**What’s the difference from a 504?**A 502 is an invalid reply from the server behind the gateway; a 504 is no reply in time. Both point behind the gateway, but one is a bad answer and the other is a slow one.

**Why does it come and go?**Intermittent 502s usually mean load or a process restarting. If they cluster at busy times, look at resources or a heavy plugin.

## New Hosting Plan with 80% OFF

Upgrade your website’s home without the heavy bill. Get new [hosting plan](https://jethost.com/web-hosting/ "Web hosting with free SSH access") with a huge 80% discount. Get free SSL, email accounts, and a control panel to manage your site. Enjoy fast performance, secure environment, and 24/7 support - all in one affordable package.

## Need more help?

Still hitting a 502 on a site you host with us? Open a ticket through Client Area → Support Tickets and we’ll check the server, PHP and any CDN.
