Joswig Solutions

IT Provider for Your Digital Business

[Fixed] 502 Bad Gateway Error on WordPress Website

502 bad gateway error

Seeing the “502 bad gateway WordPress” error on your site?

This is one of the most common errors to appear on a WordPress website. It’s also one of the most frustrating WordPress errors because it’s hard to pinpoint the exact reason for its appearance. 

That’s why in this article, we are covering all the different reasons your site could be throwing the 502 bad gateway error. 

After learning why the error appeared on your site, you can remove it with the help of our tutorial below.

Let’s get started. 

What is a 502 Bad Gateway Error? 

The 502 bad gateway error occurs when your browser is unable to get a response from your web server. 

The web server hosts your website. Whenever you open a page from your site, the browser sends one or more requests to your server. When everything goes well, the server responds with your requested page. If not, then WordPress throws an error like the 404 not found error, 403 forbidden error, 503 services unavailable error, 502 bad gateway error, etc. 

The 502 error shows up when the server is taking way too long to respond to a request. That’s because a lot goes on, between the request and the response. 

When the browser sends a request, it may have to pass through many proxy servers and sometimes multiple web servers before it can get a response from your web server. Any issue with any of these servers can cause a delay in response. 

This is why finding the exact reason behind the 502 bad gateway WordPress error is so difficult. 

In the next section, we are going to list down all the possible reasons along with their solutions. But before diving in, let’s take a look at the 502 error variations.

502 bad gateway error

502 Error Variations

The 502 error has many variations because of different operating systems, web servers, and browsers. That said, they all indicate the same problem and can be removed using the solutions in the next section. 

Take a quick look at all the 502 bad gateway WordPress errors:

  • Error 502
  • HTTP 502
  • 502 Proxy Error
  • 502 Bad Gateway
  • Temporary Error (502)
  • 502 bad gateway Cloudflare
  • HTTP Error 502 – Bad Gateway
  • 502 Service Temporarily Overloaded
  • Bad Gateway: The proxy server received an invalid response from an upstream server
  • 502 Server Error: The server encountered a temporary error and could not complete your request

Now, let’s look at the solutions. 

Fixing the 502 Bad Gateway Error

To fix the 502 error on your WordPress website, you need to try out all the following solutions one by one until you find a solution that works for you. 

Before we begin, we strongly recommend that you take a backup of your entire site. In the following tutorial, you will need to carry out steps that can break your website. A backup will be your safety net. If something happens to your site, you can restore it back to normal with the help of the backup. 

Let’s begin with the solutions. 

1. Try Reloading the Page

We know. You have probably already tried it. But give a minute or two and try again. 

Sometimes web servers get overloaded and cause WordPress to throw the 502 error. But it’s a temporary issue. Give it some time and try reloading your site again. If you still see the error, then proceed to the next step. 

2. Check for Server Downtime 

Your web server could be down either due to maintenance work or some mishap. Downtime due to mishaps is common on bad hosting providers. 

But if your server is hosted on popular hostings like Bluehost, Hostinger, Hostgator, etc, then your site could be down due to maintenance work. 

Your hosting provider must have sent you an email notification for scheduled maintenance work. Look for it.

bluehost maintenance email

Alternatively, you can use these tools to Down for Everyone or Just Me and IsItDown to see if your server is experiencing downtime. These tools are not always right. But if they show you that your site is experiencing server downtime, do confirm it with your hosting support team. 

If your server is experiencing downtime, all you need to do is wait for it to be up and running. 

3. Check For Hardware & Connectivity Issues

On rare occasions, hardware and connectivity issues can cause the 502 bad gateway WordPress error. 

To rule out any hardware or connectivity issue, try the following: 

Connect to a different network and open the website on a different system. Still, seeing the error? Then, switch off your PC, unplug the wireless router, wait for a minute or two and restart your PC.

If the error persists, try the next solution. 

4. Try Incognito Mode & Different Browser 

To find out if it’s a browser issue, you can do two things: open the site in incognito or on a different browser like Safari, Opera Mini, Microsoft Edge, etc. 

To open the site in incognito, press:

  • Ctrl + Shift + n on Windows, Linux or Chrome OS
  • Command button + Shift + n on Mac

If the site opens in incognito or in other browsers, then your current browser is the culprit. To be more precise, one of your browser extensions is the culprit. 

Remove your all extensions by selecting the three dots on the upper right-hand corner of the browser and go to More tools > Extensions. You should see a list of all your extensions, each one carrying a Remove button. 

Each time you remove an extension, check for the error on your website. 

5. Clear Your Browser Cache

The browser is capable of storing a web page (also called caching) so that when a visitor returns to your site, the browser won’t have to re-download the page. This helps the web page load faster. 

Caching is an incredible way to make your website load faster, but there are drawbacks too. For instance, the browser cache can store a broken web page and keep showing that cached version to the visitor. 

Let’s say after the 502 bad gateway WordPress error appeared on your site, the underlying problem that caused the error was fixed. But your browser may keep showing you the cached version of the page which contains the error. 

This is why you need to remove the browser cache and then check your website. 

i. Clear Cache on Chrome

To clear the cache on your Google browser, click on the three dots in the upper right-hand corner of the browser and go to More tools > Clear browsing data. On the next page, select the Clear data button and wait for the browser to clear the cache. It will take a few seconds. 

clear cache on google chrome

ii. Clear Cache on Safari

To clear the cache on the Safari browser, go to Safari > History > Clear History. From the drop-down select All history and then hit the Clear History button. 

iii. Clear Cache on Firefox 

If you are using Firefox, then select the hamburger menu button on the top of the page, and go to Settings > Privacy & Security. Scroll down to the Cookies and Site Data section and click on the Clear Data button. 

A popup will appear with these two options: Cookies & Site Data and Cached Web. Both options are preselected. We recommend unselecting the Cookies & Site Data because if you delete site data, you will be logged out of all websites. You just need to clear the cache. So the Cached Web option should remain selected. 

Next, hit the Clear button and the Firefox browser will be cache-free within a few seconds.

iv. Clear Cache on Microsoft Edge

On Microsoft Edge, select the Menu by clicking on the three dots icon in the top right corner of the browser and then go to Settings > Privacy, search, and services. Scroll down to the Clear browsing data section and click on the Choose what to clear button. Then select only the Cached images and file option and hit the Clear Now button. 

clear cache on microsoft edge

6. Temporarily Disable CDN 

A CDN allows you to deliver the content of your site faster to your visitors but it could be the reason you are encountering the 502 error on your site. 

The CDN servers are placed between your web server and the browser. This means all browser requests are routed through the CDN server. So if something goes wrong with the CDN and it fails to respond to a browser request, WordPress will show you the 502 bad gateway error.

To check whether your CDN is the main culprit, all you need to do is disable the CDN temporarily. If it’s a CDN issue, talk to the CDN providers, and tell them that their service is causing the 502 error on your site and you can’t use the CDN unless they fix their service.

7. Temporarily Disable Firewall

Like the CDN, a firewall sits between a web server and a browser checking every incoming visitor and preventing suspicious traffic from accessing the site. 

If something goes wrong with the firewall and it fails to respond to a browser request, WordPress shows you the 502 error. 

Disable the firewall temporarily and check if the error is still showing on your website. If you don’t see the error, then reach out to the firewall developers and tell them that their plugin is causing the 502 error on your site. Don’t activate the plugin unless they fix the plugin. 

8. Flush DNS

The DNS helps link your domain name with an IP address. You are likely to come across a DNS issue when you change your host or upgrade to a better plan, or modify the nameservers. It takes up to 24 hours for the changes to be implemented. During this time, if you open your site, you will be shown the 502 bad gateway WordPress error. 

So if you made any modifications that could have led to the 502 error, we recommend sitting back for 24 hours. If the error persists, talk to your hosting support team. 

But if you didn’t make any modifications to your site, then try flushing the DNS. 

On windows, open Command Prompt and insert the following text: ipconfig /flushdns. On Mac insert this: dscacheutil -flushcache. Hit enter and your DNS will be flushed. 

flushing dns in command prompt - 502 bad gateway wordpress

9. Increase PHP Timeout Limit

Every web server has a PHP timeout limit that determines how long can a server process a request. Let’s say you are uploading a large file or using a plugin that takes a long while to process. In such cases, you are likely to exceed the PHP timeout limit and it will lead to the 502 bad gateway WordPress error. 

One way of dealing with this issue is by making sure you upload small files of PHP and use plugins and themes from reputed developers. 

Another solution is to increase the PHP timeout limit. The steps will differ from hosting to hosting. We recommend looking for a help doc by your hosting provider that shows how to increase the PHP timeout limit.

10. Check Your Plugins & Themes

The 502 error could have been caused by a bad code in a plugin or theme. You will need to deactivate all your plugins and themes to check if they are causing the issue. 

The error blocks users from accessing the site so to deactivate plugins and themes, you need to access your site’s from the backend. We’ll show you how. 

Install and activate Filezilla on your desktop. Here’s a guide to help you install the software

Next, open Filezilla and connect it with your website. This guide will show you how to make that connection.

Then go to public_html > wp-content > plugins. Rename the folder into plugins_old. This will deactivate all the plugins on your site. 

disabling plugins on filezilla - 502 bad gateway wordpress

Then, check your website. If the error is gone, it means one of the plugins is the culprit. Restore the folder’s original name. This will reactivate all the plugins. 

Open the folder and start deactivating the plugins one by one, by renaming them. Every time, you rename a plugin, check your website for the 502 error. 

Next, follow the exact process with the themes folder. 

When you find the plugin or the theme responsible for the error, delete it from your site and use an alternative. You can also reach out to the developers and seek help. 

Conclusion

The 502 bad gateway WordPress error is not an easy error to remove from your site. The reason is, that it’s hard to pinpoint the exact cause behind the error. There are too many possibilities. 

In the article, above we have covered every possibility, ranging from plugin and themes conflicts to DNS and firewall issues. From browser cache to hardware failure, and much more. 

If you tried all the solutions in the article, you should have been able to remove the error from your website. 

While implementing our guide, if you come across any issues, let us know in the comment section below. 

2 thoughts on “[Fixed] 502 Bad Gateway Error on WordPress Website

Leave a Reply

Your email address will not be published.