When it comes to WordPress, there are a lot of different errors that can be downright frustrating and confusing. A few that come to mind are the Missing a Temporary Folder Error or the 400 Bad Request Error.
The 502 bad gateway error, however, is even more popular and concerns all the internet, not only WordPress.
Because it can be caused by so many different things, this error can be time-consuming to troubleshoot.
Here, I will guide you through the steps to fix the 502 bad gateways error in WordPress.
This error code explains that the client received an invalid response from an inbound server: when the requested page cannot be delivered by your WordPress hosting server, it triggers a 502 bad gateway error.
Your browser sends a request to a web server whenever you visit a website. Upon receiving a request, the web server processes it, and then sends back the requested resources along with an HTTP header & status code.
Usually, an HTTP status code isn’t displayed unless there’s a problem. In essence, it is the server’s way of notifying you that something went wrong, plus instructions on how to correct it.
Many different types of 500 status errors exist (500, 501, 502, 503, 504, etc.) and each with a different meaning but they all fall into the same category: 500 error codes mean that the request was accepted by the server, but the request could not be fulfilled.
A 502 bad gateway error can appear in a variety of ways depending on the browser, web server, and operating system:
However, they all refer to the same thing.
Usually, 502 bad gateway errors occur when your request takes too long to be processed by the server. High traffic can cause a temporary glitch to cause this delay. A poorly coded WordPress theme or plugin could also be to blame. Furthermore, it can also be caused by server misconfiguration.
Usually, this error is triggered when the server can’t find the reason for the invalid response. In practice, this means we will attempt different troubleshooting techniques until we find the problem.
Due to increased traffic or low server resources, your server may sometimes take longer to respond. Usually, the problem will resolve by itself in a few minutes. Reload the web page you are viewing to see if that was the cause of the problem.
In that case, you do not need to continue reading. However, If you encounter this error often, I invite you to keep reading since there may be something else to look at.
Although the issue has been fixed, you will still see the 502 error because the browser is loading your website from cache.
To fix this, just refresh your browser’s cache.
It is also possible for a 502 gateway error to originate from a DNS issue, such as a domain not resolving to the correct IP address or an inactive DNS server.
You should wait for things to propagate fully after migrating a WordPress site to a new host, which may take up to 24 hours in some cases.
A problem with your content delivery network (CDN) or firewall may also be to blame. The easiest way to troubleshoot this if you are using a 3rd-party CDN provider is to temporarily disable it.
It can also happen with providers who provide DDO-oS protection, such as Cloudflare. If you are having 502 errors with Cloudfare, please reach out Cloudfare’s support.
Sometimes, scripts and queries are canceled by the server due to bad code in your WordPress site, possibly from a 3rd-party plugin or theme. The 502 error has also arisen from caching plugins that have been configured incorrectly. One way to troubleshoot this is by deactivating all your plugins.
Don’t worry, deactivating a plugin won’t erase your data.
A quick way to do this if you still have access to the admin interface is to browse to “Plugins” and click “Deactivate” from the bulk actions menu. It will disable all your plugins. This may fix the issue, but you’ll still have to find the culprit. Activate each one at a time, and reload the website after each activation. If you see the 502 gateway error, you’ve found the problem plugin.
To receive help, you can contact the plugin’s developer or submit a request in the WordPress support forum.
Alternatively, if you can’t access your admin, you can access your server via FTP and rename your plugins folder to something like plugins_debug. Check again your website. If it works, you will need to test each plugin individually.
Your plugin folder should now be named “plugins” again, then you should rename every plugin folder within it, one by one, until you find the guilty one.
Always ensure that your WordPress plugins, themes, and core are up-to-date. Additionally, verify that you’re running an up-to-date version of PHP. You can use WP Umbrella to monitor all these informations!
When all the above troubleshooting steps fail, then it is likely that there is a problem with your hosting server.
The problem can be resolved by contacting your hosting company’s support team. You can tell them all the steps you’ve taken to troubleshoot the problem, it will help us to troubleshoot the issue more quickly.
An issue caused by a misconfigured server can usually be resolved quickly by all good WordPress service providers. If you are looking for an amazing WordPress provider, we recommend you to go to Kinsta.
That’s all. I hope this article helped you learn how to troubleshoot the 502 bad gateway error in WordPress.
You may also be interested in my article on How to Fix 500 Internal Server Error on WordPress.