In WordPress, there are various types of errors that are sometimes confusing and frustrating. Some famous WordPress errors are “error establishing a database connection” and “white screen of death.” However, the most frustrating error is 502 bad gateway errors. It’s serious because it happens all over the web, not just on WordPress sites but also on popular services like Gmail and Cloudflare.
In this blog post, we are covering the impact of WordPress 502 bad gateway on WP sites. Let’s dive in and find the causes and related solutions to this error:
What is a WordPress 502 Error?
The HTTP 502 Bad Gateway server error response code means that the server, which was acting as a gateway or proxy, got an invalid response from the server further upstream.
When you click on the website’s URL, your web browser sends a request to the internet server. The server then processes the request and sends it back with the HTTP status code and HTTP header. Normally, the HTTP status code remains invisible unless something goes wrong. This is the web server’s way of notifying the request sender or user that something unusual has happened alongside how to diagnose it.
There are various forms of 500 status code errors, including 500, 501, 502, 503, 504, 508, and 520. All these errors have different meanings. These error types show that the request has been accepted but somehow the request hasn’t been fulfilled.
How to Fix the 502 BAD Gateway WordPress
Before you start troubleshooting, you should do a quick test to establish whether your server is properly responding or not. One way to run the test is to try the ‘traceroute’ run. Through a traceroute, you can determine whether your server is reachable in the beginning or not. If the server is reachable, you need to find the cause of the error at your end. In the opposite case, you need to contact your hosting service provider. Resetting the router and checking the DNS settings is also a solution.
Above are basic steps to throw 502 bad gateway errors away, and you can do this without any external help. If nothing works as mentioned above, you can do the following to troubleshoot the WordPress 502 error.
1-Clear Your Browser Cache
The WordPress 502 error occurs when someone tries to access a website, even when the underlying issue has been resolved. This happens when the browser is dependent on its cache instead of processing the latest version of the website from the server. Sometimes, if the user reloads the site several times, the error vanishes, especially when the user is using Forced Reloading through Shift+CTRL+R on Windows or Shift+CMD+R on Mac.
If none of the above works, you can go towards emptying the browser’s cache. If the user’s browser is Chrome, they can do this: go to Settings, proceed to the Advanced menu, and find the Clear Browsing Data option.
Search for the option “Cached images and files” under the basic tab. Now click “Clear Data” after choosing it. Remember that this menu will delete your browsing history if you keep turning on that setting before clicking the “Clear Data” button.
You can also complete the above process through Safari, Firefox, or any other web browser. After clearing your cache, try to reload your WordPress site once more. If the error persists, try some other serious tactics.
2-Temporarily Disable Your Content Delivery Network (CDN)
A few services, such as CDN, rely on the reverse proxy tactic for seamless incoming traffic routing. However, as an extra layer, the proxy can create problems when you try to connect to where the website’s origin is. In this case, your site visitors may run across the fiery WordPress 502 bad gateway.
Fortunately, there is an easy way to check whether or not your CDN is causing the problem. You only need to disable the service temporarily and see if the website is reloading correctly without it. How simple or complex the process of CDN disability is depends upon your hosting service. However, it is normally simple.
For example, if you are a Cloudflare user, you must navigate to the dashboard’s overview tab. There you will see a rundown of properties running the service. Here you will have to look for a “Pause” button and click on it. It will be in the “Pause Website” section.
Now, there will be no middlemen between you or anyone accessing the website and the server origin. If 502 Bad Gateway WordPress is resolved, your CDN will be the culprit. In most cases, you only need to wait for some time before re-enabling the service.
3-Check Your Themes and Plugins
Normally, the bad code on the WordPress site is the reason behind queries and scripts being canceled by the server. The bad code can possibly happen due to a third-party theme or plugin. Quite a few misconfigured caching plugins also generate the WordPress 502 error. One of the few ways to troubleshoot this error is by deactivating all your plugins. Don’t worry! You won’t lose any data by plugin deactivation.
If you can still access the domain, a fast way to do this is to browse ‘plugins’ and choose ‘deactivate’ from the “Bulk action” menu, and all your plugins will be deactivated. Now, activate plugins one by one and reload the WordPress site after each activation. If the WordPress 502 error returns, it shows you have caught the misbehaving plugin. Now, you need to contact the plugin’s developer for help.
In the case of non-access to your admin, you still have the option to FTP into your server to rename the plugin folder and then check the website again. If renaming works, test each plugin one by one. Keep restoring old plugin names until you find the misbehaving folder.
It is important to ensure your themes, plugins, and WP core are up to date. Also, check to ensure you are running the supported PHP version. Reach out to your hosting service for assistance.
There may also be some more fixes to troubleshoot the WordPress 502 error on your WordPress website. Usually, this error is an issue with the hosting service provider and not on the client-side. Third-party themes and plugins with unoptimized queries or bad code are also things to cater to. If you are stuck on the 500 bad gateway errors on your WP site and remain stuck after a few minutes, the problem may be on your end. So, you can go through the processes and solutions mentioned above, and you or your users should be back on your site in no time.