How to Fix 502 Bad Gateway WordPress Error

How to Fix 502 Bad Gateway WordPress Error

502 Bad Gateway WordPress error is one of those errors you are likely going to see if you use WordPress long enough. It’s a proxy error that happens quite frequently, and chances are you have experienced it on several occasions.

502 Bad Gateway Error

502 Bad Gateway issue is a server error. That is to say, the error originates from the webserver of a site, and not your machine.

It is indicative that a server encountered difficulties processing a request coming from your browser.

Though a temporary error, Bad Gateway error can be frustrating. It affects WordPress sites as well as non-WordPress sites.

Thankfully, this error can be fixed. In this article, we will be sharing with you some of the methods for fixing Bad Gateway Error.

What is 502 Bad Gateway Error?

To load a webpage, your browser will first send an HTTP request to the webserver where the website is located.

In essence, the HTTP request tells the server, “Hey, someone requested Z page, and I need you to fetch it”.

Two servers are needed to complete your request: the gateway or proxy server and the upstream server (also called the origin server).

The proxy server (also referred to as edge servers) receives the request first, before then transmitting it to the origin server.

If the origin server fails to respond back or the upstream server received an invalid response, what you will get is a 502 Bad Gateway error.

In essence, Bad Gateway error means there’s a problem with a server holding a website.

Different Variations of 502 Bad Gateway Error

Bad Gateway error comes in different forms, with each slightly different from each other. They are as follows:

  • Bad Gateway NGINX
  • 502 Bad Gateway Cloudflare
  • HTTP Status Code Error
  • 502 Service Temporarily Overloaded
  • HTTP Error 502
  • Server Error 502: The server encountered a temporary error and could not complete your request
  • 502. That’s an error

While 502 is the most common error code indicative of a server problem, there are many other error codes that point to the same problem. They are 500, 501, 503, and 504 error codes.

Depending on the website you are visiting, the error messages will be displayed differently.

For instance, you might have seen this screen while on Twitter.

Twitter Error


This is a typical HTTP 502 error, indicative of something wrong with Twitter servers.

On Google, the error is displayed as follows.


Yet another gateway error displayed differently.

What Causes 502 Bad Gateway Error?

When a 502 error occurs, a couple of factors might be responsible. A few of them are discussed below.

Heavy Traffic

A sudden spike in traffic to a website can cause the webserver to malfunction. When this happens, the server becomes temporarily overloaded. The result is a connection breakdown between the proxy and the upstream server.

The Proxy or Upstream Server Becomes Inaccessible

If the proxy server, whose primary job is to act as a signal receiver, becomes inaccessible, the end result is 502 Gateway error. The same goes for the upstream server.

These servers may go down because of a power outage, poor internet connectivity, etc.

Outdated Browsers

A browser that is outdated may fail to function as it should. A dysfunctional browser, more often than not, experiences caching problems. This, in addition to signal flow and database connection problems, causes a 502 error.

Firewall Security Problems

Certain DDoS protection systems often become the cause 502 error problem. Rather than guarding against DDoS (Distributed Denial of Service) attack, for which they were designed, they take things a bit too far.

They end up setting up a firewall between the proxy and upstream server, thus blocking off the communication between them.

How to Resolve 502 Bad Gateway Error

While it’s true that 502 Bad Gateway is a server-side HTTP error, there are a couple of things you can do to get it fixed. Let’s see a few of them.

Refresh Your Browser To Clear 502 Bad Gateway

This one is your first point of call. Simply reloading the webpage can clear up this error. Like we earlier said, poor internet connectivity issues can cause a 502 error.

If that’s the case, reloading the page after a minute or so can help.

Clear Your Browser’s Cache And Cookies

If after reloading the webpage repeatedly you still have this error, another thing you should do is clear your browser cache.

It might be that a piece of data stored on your computer is causing the browser to malfunction.

To clear your browser cache, on the P.C, press Ctrl + Shift + Delete. This works for Chrome, Mozilla Firefox, and Internet Explorer.

Then select cache and/or cookies, click Clear Data.

Cache and Cookies

Another way to do it is by performing a hard refresh. Simply hold down the Ctrl + F5 keys.

Run Your Browser in Safe Mode

Chrome, Firefox, and Internet Explorer can be opened in safe mode. For Chrome, simply click Ctrl + Shift + N on the P.C to launch the incognito mode.

For Mozilla Firefox, simply hold down the Shift key on the PC, and double-click the browser icon.

It is a bit different for Internet Explorer. First, you have to press Windows key + R. Next, type iexplore-extoff.

Running your browser in safe mode will force all extensions and add-ons to be disabled. If this method works, know that an extension/add-on on your browser is causing the problem.

Deactivate and Delete Duplicate Plugins Possibly Causing 502 bad Gateway

At times, having two plugins that serve the same function can cause server error. This is very common with caching plugins.

So, if you have a duplicate plugin on your WordPress site, uninstall it. This is also applicable to redundant plugins you aren’t using. Don’t leave them lying around on your site. Instead, delete them.

If this still doesn’t work, temporarily disable all your plugins to see if a particular plugin is a problem. If this error is preventing you from accessing your Dashboard, you will need to disable plugins manually.

Check Your Server’s DNS Settings

If you recently moved your website to a new host, this move will change where your DNS servers point to. This also happens when your website’s IP address is changed.

If this is the source of the problem, the simplest thing to do is to wait for 24 hours for the DNS changes to resolve on its own.

Alternatively, you can try your hands on another DNS service provider to see if things will work. A good example is Google public DNS.

Turn Off Your CDN

If you run your website on a Content Delivery Network, there is a good chance the problem might be coming from there.  Often times, firewall block off requests from a CDN.

As such, temporarily turn off your CDN and see if it will fix the issue. If it does, check your firewall configuration and make necessary corrections.

Restart Your Computer

Though simple, this works especially if poor connectivity is the culprit. If you are working with networking equipment, also restart it.

Contact Your Hosting Provider

If you have tried all these steps and nothing works, simply reach out to your hosting provider. They have the expertise and skill to diagnose and resolve the 502 error problem.


Bad Gateway error can be frustrating, but there are a couple of things you can do to have it resolved.

We’ve shared a list of them in this article. Some are so simple that all you need to do is to click one or two buttons.

The last resort is reaching out to your hosting provider if the problem persists. They can usually identify the source of the issue and help you fix it.

More Resources: