502 Bad Gateway: What It Means and How to Fix It

A 502 Bad Gateway error means one server passed your request on to another server and got back an invalid or broken answer. The server showing you the error is the "gateway" -- it's working, but whatever sits behind it didn't reply properly. This guide explains what a 502 Bad Gateway means on our hosting, how to tell where it comes from, and how to fix it.

What the 502 error looks like

  • 502 Bad Gateway, sometimes with the name of the server software underneath.
  • Chrome and Edge: "This page isn't working ... HTTP ERROR 502".
  • A branded page from a CDN such as Cloudflare saying "Bad gateway", with a diagram showing your browser, the CDN and the "Host" and which one failed.
  • "Proxy Error" or "The proxy server received an invalid response from an upstream server".

Where a 502 comes from

A 502 always involves two servers talking to each other. On our hosting that's usually one of these:

SetupWhat's happening
You use Cloudflare, Sucuri or another CDN/proxyThe CDN is the gateway. It reached our server but didn't get a valid response -- or it couldn't connect to the right place at all (for example a wrong IP address in its DNS settings or an SSL mode mismatch).
Your site calls another serviceYour site, or a plugin on it, forwards requests to an outside API or app that returned garbage. The 502 may appear only on certain pages (checkout, search, a feed).
The web server and PHPLiteSpeed hands PHP pages to a PHP process. If that process crashes or exits mid-request, the web server may return an error instead of your page. On Instant Access Internet Services servers this usually shows as a 500 or 503, but a 502 is possible.

How to fix it as a visitor

  1. Wait a minute and reload the page. Many 502s are momentary.
  2. Try another browser or a private window, and another network (mobile data instead of Wi-Fi).
  3. If you use a VPN or proxy, turn it off and try again. MDN notes that client-side networking (proxy, VPN, firewall or DNS settings) can also produce this error.

How to fix a 502 on your website

1. Check whether a CDN is involved

If the error page has Cloudflare (or another CDN) branding, or your domain's nameservers point to that CDN, start here:

  1. Pause the CDN or set the record to DNS-only for a few minutes, then load the site. If the site works directly, the problem is between the CDN and our server.
  2. In the CDN's DNS settings, make sure the A record for your domain points to your hosting account's IP address (shown in cPanel under General Information on the right of the home page, as "Shared IP Address" or "Dedicated IP Address").
  3. Check the CDN's SSL setting. Use the "Full" or "Full (strict)" option -- our AutoSSL certificate makes this work. Don't use a mode that connects to our server over plain HTTP on a site that forces HTTPS, or you may get errors or redirect loops.
  4. If the CDN still can't connect, check the CDN's own status page and support resources, or open a ticket and we'll confirm your site is responding normally on our side.

2. Check your error logs

  • In cPanel, go to Metrics > Errors for recent web server errors.
  • In Files > File Manager, open error_log in the folder of the failing page (for WordPress, usually public_html or wp-admin) and look at the newest lines. A PHP Fatal error points to the plugin, theme or script at fault.

3. Rule out a PHP or plugin crash

  1. Think about what changed just before the error: a plugin or theme update, a PHP version change, a new script.
  2. If you recently changed PHP versions in Software > MultiPHP Manager, switch back and test.
  3. For WordPress, disable plugins by renaming wp-content/plugins to plugins.off in File Manager. If the site loads, rename it back and reactivate plugins one at a time to find the culprit.

4. Check your resource usage

In cPanel, go to Metrics > Resource Usage. If your account is hitting its limits (60 simultaneous PHP requests, 2 GB memory, 100 processes), requests can fail. Turning on LiteSpeed Cache and removing heavy plugins usually fixes this.

5. Check outside services

If the 502 appears only on one feature (payments, shipping rates, a live feed), check that service's status page and your plugin's logs. You may need to wait for the provider to recover or update the plugin that talks to it.

Common questions

What's the difference between 502 and 504?

Both involve a gateway and a server behind it. A 502 means the server behind it sent back an invalid response. A 504 Gateway Timeout means it sent no response in time.

What's the difference between 502 and 500?

A 500 comes from the server running your site itself. A 502 points to a problem between two servers in the chain.

Does a 502 affect my search rankings?

A brief 502 won't. If it lasts hours or days, search engines may slow crawling and eventually drop pages, so fix it promptly.

When to open a ticket

Open a ticket if the site fails without the CDN too, if the logs show nothing, or if cPanel or webmail also show errors. Include the full URL, the time, whether you use a CDN (and which one), a screenshot of the error page, and your IP address from whatismyipaddress.com.

Related guides

Still stuck? Open a support ticket and the Instant Access Internet Services team will help.

Ultrafast LiteSpeed hosting from InstantAccess.net: free SSL, free backups, cPanel included, no contracts. Check out our $10/month hosting.
  • 502 bad gateway, http error 502, 502 bad gateway cloudflare, 502 error wordpress, bad gateway error fix, 502 proxy error
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

429 Too Many Requests: What It Means and How to Fix It

A 429 Too Many Requests error means something decided that one visitor, program or website sent...

500 Internal Server Error: What It Means and How to Fix It

A 500 Internal Server Error means the web server hit a problem it couldn't recover from while...

400 Bad Request Error: What It Means and How to Fix It

A 400 Bad Request error means the server received a request it couldn't understand, so it refused...

401 Unauthorized Error: What It Means and How to Fix It

A 401 Unauthorized error means the page you asked for needs a login, and the server didn't...

403 Forbidden Error: What It Means and How to Fix It

A 403 Forbidden error means the server understood the request but refused to show the page....