How to Fix 502 Bad Gateway Error in WordPress?

Fix 502 Bad Gateway Error in WordPress

0 Comment

10 mins Read

Fix 502 Bad Gateway Error in WordPress

In this article, we will explain one of the WordPress errors known as the 502 error code and will tell you how to fix 502 bad gateway error in WordPress. When it comes to a website (especially a WordPress one), there are always a lot of errors or different kinds of failures that can be frustrating.

You might probably encounter one of the WordPress common errors such as HTTP 404, HTTP 429 too many requests, or even this error: “upload filed to write file to disk”. Some of them can be fixed as easily as ABC, while other errors may be frightening (e.g. white screen of death).

In this article, we will speak about one of these errors known as the 502 error code. We will tell you how to fix 502 bad gateway errors in WordPress. But, before that, let’s start with its definition.

What is a 502 Bad Gateway Error?

Fix 502 Bad Gateway Error in WordPress

To fix 502 bad gateway error in WordPress, first, you should know what the meaning of this code is, and when it happens. HTTP code 502 is a common error that happened when you are trying to visit a web page while the server gets an invalid response from another web server. In fact, this error is a server-side error and rarely caused by Wi-Fi connections or computers of users.

In fact, 502 bad gateway meaning is the error that is related to the server you are going to visit. This error is also known as 502 error code, HTTP 502 error, error reference number: 502, HTTP status code 502, and WordPress 502 error. Below is a list of different variations you might see on the web:

  • “502 bad gateway”
  • “Error 502”
  • “HTTP 502”
  • Temporary Error (502)
  • “502 Proxy Error”
  • That’s an Error
  • “HTTP Error 502 – Bad Gateway”
  • Bad Gateway: The Proxy server received an invalid response from an upstream server.
  • 502 bad gateway Cloudflare
  • “502 Service Temporary Overloaded”
  • A blank white screen
  • “502 Server Error: The server encountered a temporary error and could not complete your request”
Start Blogging Start Blogging

Self-host your WordPress on top-tier hardware, featuring NVMe storage and minimal latency around the world — choose your favorite distro.

Get WordPress VPS

Another variation can be: “502 – Web server received an invalid response while acting as a gateway or proxy server”. In this case, there is a problem with the page you are looking for, and can’t be displayed. In this error and HTTP status code 503, you can’t preciously tell what happened and what’s going wrong. But there are common issues that some of them will explain in the next paragraph.

Why does 502 Error happen?

why 502 error happens

Every time you visit a website, the browser will send a request to your web server. The web server receives all requests and starts processing them. Then, these requests will send back to the browsers along with HTTP status codes and an HTTP header. If the process goes wrong or any problem occurs, you can see these errors. In fact, these codes are the language of your server to notify you that something goes wrong.

As you probably know, there are different kinds of HTTP status codes (e.g. 500, 501, 502, 503, 520, etc.) that are different meanings, and 502 bad gateway meaning indicates that when a server acts as a gateway or a proxy, happening of this error will be probable. Below are three main issues that cause 502 bad gateway responses. These includes:

  1. Origin Server Down: in this situation, the server is not reachable. This may occur when the server is down or there is no connectivity to the server.
  2. Firewall Block Request: when the firewall blocks the communication between the main server and edge server, occurring this error will be probable. This can also occur by the security plugins of your content management system.
  3. Domain Name Not Resolvable: sometimes, the domain name is not resolving to the correct IP and it is important to note that DNS changes to a new server take some time to completely propagate and be active. So it may cause the 502 error in WordPress sites.

“Also read: How to Fix the HTTPS Not Secure Message in Chrome

How 502 Errors Can Negatively Affect Your SEO?

how can 502 error affect on your seo

You should hurry to fix 502 bad gateway error in WordPress because it negatively affects the SEO of your site. If your site remains down for only 10 minutes, the crawlers will simply deliver the page from the cache. You may also lose the chance of re-crawling.

If your site is down for an extended period of time (i.e. 6+ hours), then Google might see this error as a site-level issue that should be addressed. This problem can highly impact the ranking of your WordPress site. So, try to fix this problem as soon as possible.

15 Ways to Fix the 502 Bad Gateway Error?

15 ways to fix 502 error

Although facing an error in a WordPress site is frightening, you can simply fix the 502 bad gateway error most of the time with ease. In the following, we will provide you with a few solutions for fixing this error:

1. Try to Refresh the page

Bad gateway errors are automatically resolved themselves after some hours or even days! If you’ve got time, then sit back, stay relax and try again. However, if you want to fix the problem quickly, then reloading the page is a good idea. One tip for you to remember is once you meet an error in your browser, the first thing you should do is to refresh the page.

In case you’re on Windows and want to reload, try to press Ctrl + R, or if you’re on Mac, simply refresh by pressing Command + RIf you still have the issue with the 502 error, proceed to the next step.

2. Clear the cache

Once you refreshed the tab and nothing happened, it’s time to clear the browser’s cache.

Also Read: Clear DNS Cache – How to Flush DNS?

To do this is actually easy; all you need to do is to perform a hard refresh! You can also go in settings and manually delete the cache, but why do you want to go a long way? Do run a hard refresh, and yeah!

Windows users can press Ctrl+ Shift + F5 to do a hard reload. If you’re on Mac, then do Command + Shift + F5. Linux users only need to press F5 to do it.

Start Blogging Start Blogging

Self-host your WordPress on top-tier hardware, featuring NVMe storage and minimal latency around the world — choose your favorite distro.

Get WordPress VPS

3. Try incognito window

Browser extensions can sometimes cause problems. That’s why it’s recommended to disable some of them if you don’t use them at the moment. You might have lots of extensions, and disabling one by one can be boring! There’s even a percentage that the problem won’t get resolved by only disabling; removing them is also a problem because you may want to keep them always with you.

Nonetheless, try to go into incognito mode on your browser, so you don’t need to remove your extensions. Incognito mode also helps you exclude cookies, site data, and all other information that has been previously saved so that you’ll experience normal browsing.

4. Restart your device and network equipment

Temporary errors are also engaged here that may occur from time to time. You should reset not only your device but also your network equipment. This way, you’ll get rid of those temp things that come to you off and on.

5. Use another browser

Different browsers offer distinct features that work best for you on certain websites you use. It’s also advised to use Chrome or Firefox to check if your browser is corrupted. So, it makes good sense to change it right now!

6. Test on another device

Granted on specific terms, it’s apparent that you’d experience differently on different devices. This error is no exception. Try to load the website on another desktop or mobile browser, but keep in mind that you should also change the network, so there you go!

7. Check out the site status

Websites might momentarily get down for different purposes, and it’s sometimes out of any reason. To know if a website is down, check out Is It Down Right Now.

If none of the solutions above could fix the problem, move on steps below.

8. Look for Server Connectivity Issues

Most websites run on third-party hosting providers or multiple servers. If your server is down and your website shows your visitors this error, to fix 502 bad gateway error in WordPress you’d better wait for your server to finish maintenance or fix the problem causing the error.

Start Blogging Start Blogging

Self-host your WordPress on top-tier hardware, featuring NVMe storage and minimal latency around the world — choose your favorite distro.

Get WordPress VPS

9. Check the Situations with Your Host

Sometimes, a script, a query, or a request will take too long so that it will be canceled or killed by the server. In fact, all of these processes will terminate after a certain period of time. Therefore, the error 502 bad gateway fix process can be done via contacting your WordPress hosting provider.

One problem connected to your host is that the platform runs in a non-isolated container. It means that the software that runs each site is a shared one and is not completely private. This greatly increased the chance of seeing 502 bad gateway errors.

Another reason for seeing HTTP status code 502 is because of the fact that the server is not reachable. It means that there is no connectivity or the server is down. So, you’d better contact your host by calling them or sending a ticket. You can also run a ping test to see if messages are reaching your IP or not.

Also Read: How to Fix 504 Gateway timeout Error in WordPress?

10. Check Your Plugins and Themes

A lot of times misused plugins or themes may cause an error. Sometimes, scripts and queries will be canceled because of bad code in WordPress themes or plugins. We have also seen a lot of misconfigured caching plugins that generate a 502 error.

In these cases, the first action can be deactivating them. Then, start to activate them one by one to fix 502 bad gateway errors in WordPress. Always, make sure to update your website plugins to the latest version, and check to ensure you are running a supported version of PHP.

11. Temporarily Disable CDN or Firewall (Faulty Firewall Configurations)

Sometimes, the real cause of 502 error code is related to your website’s firewall or Content Delivery Networks (CDNs). The simplest way, in this case, is to temporarily disable the CDNs if you are using a CDN third-party. You may also be using some plugins for CDNs, so to fix 502 bad gateway error in WordPress, simply deactivate your related plugins.

This error can also happen with providers providing DDoS (Distributed-Denial-of-Attacks) protection, or fully proxy services like Cloudflare that have extra firewalls. This sometimes will happen in Cloudflare’s free plan. Unfortunately, there is no quick solution in this case, since Cloudflare is a fully proxy service. In fact, you’d better know that there are two different 502 bad gateway error variations with Cloudflare as seen below:

  • When the problem is connected to your host.
  • When the problem is a problem on Cloudflare’s end.

Sometimes, a full firewall configuration will cause the 502 bad gateway error. In this process, a request from a content delivery network will deem as an attack on your server so that the server will reject it. As a result, a 502 bad gateway error occur. To fix the error in this situation, check your firewall configuration to fix the problem.

12. Check Logs

The error log will often help you to fix 502 bad gateway errors in WordPress. Some hosting providers provide you with logs so you can easily see the errors in the log viewer, and quickly fix the issue. This method will help you especially when a plugin is caused the error 502 in WordPress. If your hosting provider doesn’t have a logging tool, you can easily add the following code to your wp-config.php file.

define ("WP_DEBUG', true);
define ("WP_DEBUG_LOG', true);
define ("WP_DEBUG_DISPLAY', false);

You can also check log files in Apache and NGINX, which commonly are located in the following path:

  • Apache: /var/log/apache2/error.log
  • NGINX: /var/log/nginx/error.log

13. DNS Issue

When your WordPress site has just migrated to a new host, the DNS issue may cause a 502 error. In this situation, you’d better wait for things to fully propagate from the old host to the new one. This completely depends upon the TTL value of your DNS records. You can also try flush DNS. Flushing your local DNS cache is something like clearing your browser cache.

For the Windows platform, open up a command prompt and type the following:

Ipconfig / flushdns

If it worked, you can see a “Successfully flushed the DNS resolver Cache” message. For macOS users, enter the following in a terminal:

dscacheutil –flushcache

Remember that macOS has no success message for this terminal. You can temporarily change your DNS server. For example, you can change it to a public DNS server such as Google. In some cases, it really works.

14. Restart PHP

Another solution to fix 502 bad gateway error in WordPress is restarting PHP. Some hosting providers provide a tool to make this process easy. But if your host doesn’t provide any tool, you can always ask your hosting support team to restart PHP.

15. PHP Timeout Issue

If you are doing big WordPress imports, PHP Timeout will occur. When this error happens a 502 error will display. In this situation, a single PHP process runs for longer than the max_execution_time or max_input_time. By changing these values, you can fix 502 bad gateway error in WordPress.

Start Blogging Start Blogging

Self-host your WordPress on top-tier hardware, featuring NVMe storage and minimal latency around the world — choose your favorite distro.

Get WordPress VPS

Conclusion

When your WordPress hosting gets an invalid response for the requested page, a 502 error will occur. In this article, we’d discussed 502 bad gateway error in WordPress as well as three main issues that cause this kind of HTTP Status Codes. This error is quite annoying because it can be created with a lot of different things.

Therefore, the process of troubleshooting and finding the real cause takes some time. But, with the suggested solutions we’ve discussed, you can save your time and fix the 502 bad gateway error in WordPress sites.

FAQ

What Does Error 502 Mean?

The HTTP Error 502 means a server error and indicates that the server is acting as a proxy or a gateway. The troubleshooting of this error is a bit annoying because the various things can cause it.

How Do I Fix Error 502?

To fix the error 502 bad gateway, you can try the following solutions:

  1. Refresh the page
  2. Restart your computer and networking equipment
  3. Start a new browser session or load the site with a different browser
  4. Clear the cache and cookies
  5. Contact your Internet Hosting Provider
  6. Disable your firewall
  7. Check your WordPress plugins and themes.

Is 502 Bad Gateway Error Bad?

Every error can be annoying and makes your users have an awful experience. Since this error is a general indicator that tells you there is something wrong with your site, it can be bad. Therefore, you can try to fix it as soon as possible.

Does 502 Bad Gateway Mean “I am Blocked”?

502 Bad Gateway error doesn’t really mean a block. This error indicates that the edge server was not able to get a valid response from an upstream server. Therefore, this error has happened.

What Causes Bad Gateway?

It may happen by network errors such as DNS issues, ISP-related issues, routing problems, or the problems related to the server software timeouts, or even can be created by slow queries.

An avid technical writer and a scripturient literarian.

Comments

Leave a Comment

Your email address will not be published. Required fields are marked *


Latest Posts