What is 502 Bad Gateway and How to Fix It

We figured you’d stumble across this guide eventually. Because the 502 Bad Gateway error happens all the time, even if you have great web hosting.

If you’re seeing this error message on your website, we have good news and bad news: The bad news is that the 502 Bad Gateway error can hurt your SEO if you don’t fix it as soon as you see it. This is because if you leave the 502 Bad Gateway error unattended for too long, Google will see this as a site-level problem, which will bruise your SEO ranking. And that would be a real shame after all the hard work you put in, using your SEO tool.

Now for the good news: The 502 Bad Gateway error seems complicated, but it’s actually not that hard to fix.

In this guide, we’ll tell you exactly how to fix the 502 Bad Gateway Cloudflare error, but first, let’s get into what it is.

What is the 502 Bad Gateway Cloudflare error?

Whenever you visit a website, your browser sends a request to the server that hosts the website. When everything’s working the way it’s supposed to, the server sends the webpage back, and the website loads on your device. But when things go wrong, instead of seeing the webpage, you’ll see an error message, like “404 Page not found” or “502 Bad Gateway”.

A 502 Bad Gateway Cloudflare error means that the server you were trying to connect to was acting as a proxy or gateway for another server, but it got a bad response from the other server. This can happen for a number of reasons.

For instance, the server might be overloaded, or there might be network issues between the servers, or a firewall might have been improperly configured.

502 Bad Gateway Error variations

Just like there are different ways for websites to present the “404 Page not found” error, there are different ways for sites to present the 502 Bad Gateway Cloudflare error. Here are some variations you might see:

  • Error 502
  • 502 Service Temporarily Overloaded
  • 502 Proxy Error
  • 502 Bad Gateway
  • 502 Bad Gateway Cloudflare
  • HTTP 502
  • 502 Server Error: The server encountered a temporary error and could not complete your request
  • That’s an error
  • Bad Gateway: The proxy server received an invalid response from an upstream server

Some websites are a bit more user-friendly about it. For instance, Twitter just says “Twitter is over capacity”. (The adorable picture of a floating whale being held aloft by little twitter birds also softens the blow.)

You can display your error message however you like, but visitors tend to react more positively when your message is user-friendly and on brand. And they don’t like it when you have too many error messages or when you go too long without fixing them.

So, here’s how you fix the 502 Bad Gateway Cloudflare error:

How to fix the 502 Bad Gateway Cloudflare error

1. Reload the webpage

This is one of the first things you should do when you see any error message, including the 502 Bad Gateway error. If the error message happened because the server is overloaded, waiting a while then reloading the page will usually solve the problem.

2. Clear your browser cache

Sometimes, you’ll see an error message because your browser’s cached version of the webpage is different from the current version on the website. Clearing your browser cache will force your browser to retrieve the newest copy of the webpage from the website.

To clear your cache in Google Chrome, click the three-dot icon in the top-right corner of your browser, then select More Tools >> Clear Browsing Data and check only the box for Cached images and files.

3. Check your plugins and themes

Misconfigured plugins can cause a 502 Bad Gateway Cloudflare error. To fix this, you need to deactivate your plugins. (Don’t worry: You won’t lose any data by doing this.)

To deactivate your plugins, head to Plugins >> Deactivate. If this works, your next step is to figure out which plugin was causing the issue. To do this, reactivate your plugins one by one and reload the site each time. When you see the 502 Bad Gateway Cloudflare error again, you’ll know which plugin was acting up, and you can post a support ticket in the WordPress repository or ask the plugin developer for help.

Also, make sure your plugins and themes are up to date and that you’re running a supported version of PHP.

4. Temporarily disable your CDN and firewalls

Sometimes, a 502 error can be caused by your CDN (Content Delivery Network) or firewalls. This problem is also pretty common with providers that have an extra layer of firewalls, like Cloudflare. If you specifically see the 502 Bad Gateway Cloudflare error, reach out to Cloudflare for help. Also, check their status page to see if they’re currently experiencing an issue.

If the problem is with your CDN or firewalls, temporarily disabling these should help. Once you’ve finished browsing, be sure to enable them again.

5. Check your DNS

A 502 Bad Gateway error can also be caused by a DNS problem, like the domain not mapping to the right IP address. In fact, if you’ve recently migrated your WordPress website to a new host, this is the most likely cause of the problem. To fix this, you’ll need to wait at least 24 hours for complete propagation. If you haven’t recently migrated your website, try flushing your local DNS cache by opening a command window and typing the following: ipconfig /flushdns

If you use a Mac, you’ll enter the following in the terminal, instead: dscacheutil -flushcache

The Takeaway

The 502 Bad Gateway error seems complicated, but it’s actually pretty easy to fix. Just go through this guide and try solutions one by one until something works. Good luck!