9 Possible Solutions To Fix a 502 Bad Gateway Error on Your WordPress Site
WordPress errors such as 502 bad getaway error frustrate and annoy the website owners and the users and visitors on your website. This is one of the most usual WordPress errors, and others such as the error establishing the database connection or white screen of death also create a lot of performance and other website issues.
502 bad gateway error is especially popular as it affects smaller websites and huge services such as Twitter, Gmail, CloudFlare experience this issue. This error has several potential causes, and you need to try multiple solutions to help resolve this issue.
In this blog, we will cover the following sections:
- What Is the "502 Bad Gateway Error"?
- What Causes 502 bad gateway error?
- How does the 502 gateway error impacts website’s SEO?
- How do I fix and resolve the 502 bad gateway error on my WordPress website?
What Is the "502 Bad Gateway Error"?
The 502 bad gateway server occurs when the website’s server your browser sends a request to receives an invalid request-response.
Gateway is essentially referred to as a device that is used to enable networks communications. Sometimes, your web server acts as a gateway that tries to tell you that it has received an invalid response through this error. Therefore, it is crucial to understand that this issue is a server-level error, not specifically a WordPress or your website’s issue
This invalid response could be the result of connection time-out or other different issues.
What Causes 502 Bad Gateway Error?
Before you troubleshoot this error, it is first important to figure out what is causing it. There could be several different reasons or causes of this error which includes:
- Browser errors
- Database errors
- Outdated software
- Error due to server overload
- Plugin incompatibilities
- Corrupted cookies or caches files
- Problems with a router or other home networking equipment
- Reverse proxy server problem
- An unavailable or timed-out server
- Faulty PHP scripts
How does the 502 gateway error impacts website’s SEO?
The 502 bad gateway error negatively impacts your website’s SEO (Search Engine Optimization). SEO is important for your website to perform well on the SERP (Search Engine Results Page) and to gain quality traffic.
If your website is down only for a few minutes, let’s say around 10 minutes, the crawler simply delivers the page from cache. And by the time Google re-crawls it again, you resolve the issue, and your website is up and running back again. If this is the situation, you do not have to worry about the SEO impact, and your website is completely fine
On the other hand, if you do not resolve this error right away, and your website is down for a long period for multiple hours, Google sees this error as a site-level issue that is required to be addressed. This significantly affects your rankings, and Google’s crawlers can push your website down to a lower SERP position.
If your website is consistently facing this issue and needs a solution, go through the following list of solutions that can assist you fix this error quickly and efficiently.
How do fix and resolve the 502 bad gateway error on my WordPress website?
This error is caused mainly because of the network/server issue. Or it could also be your client-side issue. Before you reach out to your hosting provider, you must implement the following strategies.
Here are some ways through which you can resolve the 502 bad gateway error and get your website up, running, and accessible to your customers again.
- Reload the page or refresh it
- Remove all cookies and caches from your web browser
- Check for the DNS Issue
- Turn off the firewall and CDN temporarily
- Verify your themes and plugins
- Check Your Logs
- Restart Wordpress Site
- PHP Timeout Issue
- Contact your host provider`
1. Reload the page or refresh it
Whenever you encounter the 502 bad gateway error, one of the simplest solutions and the first step to fix this issue is to try reloading your website (F5 or Ctrl + F5).
Your server or host may be simply overloaded. So once you reload or refresh your web page, it can help solve the issue, bringing the site back. Meanwhile, you can also try loading the website on a different browser, such as Mozilla Firefox, Microsoft Edge, or Safari, to check if it works on those browsers.
Another simple solution, while you are waiting to load your website, is to paste your website’s URL into downforeveryoneorjustme.com. This solution will ensure if your website is really down or if it is a problem on your side.
2. Remove all cookies and caches from your web browser
Clearing your browser’s cache can also sometimes help errors like this and instantly fix them. This solution varies from browser to browser and depends on which browser you are using.
On Google, you can clear your browser’s cache by clicking on the three-dot icon on the right-side corner of your window. Click on Settings, and then on Privacy and Security. Click on the first prompted option, which is Clear browsing data, which will open a pop-up window.
Make sure to check the check boxes beside Cached Image & files, Cookies and other site data. And then click on the Clear data tab.
Once you complete this process, close the settings page, and reload your website’s page. If the error was because of the cookies and caches, the error should be gone now, and your website should run smoothly and efficiently.
3. Check for the DNS Issue
The 502 error could also be caused by the DNS issues, such as the DNS server not responding or the domain not getting resolved to the correct IP.
If you have just recently migrated your WordPress website to a new host, it is crucial to wait for a while until things fully propagate. Sometimes, you will also have to wait for over 24 hours, as it depends upon the Time To Live (TTL) value of your DNS (Domain Name Server) records.
Or you can also try flushing your local DNS cache, which is similar to clearing your browser’s cache.
You can implement this solution by entering the following code:
i.) From your Windows machine’s command prompt:
ipconfig/flushdns
If it runs successfully, you shall see the “Successfully flushed the DNS resolver Cache” message.
ii.) For MAC OS users, you must enter the following code in the terminal:
dscacheutil -flushcache
You won’t see a success message here on macOS as you see on Windows.
You could also try temporarily changing your DNS servers to a public DNS server.
4. Turn off the firewall and CDN temporarily
The 502 bad gateway error could also be because of an issue with your firewall of a CDN (Content Delivery Network). It is wise and preferable to temporarily disable your CDN if you use a third-party CDN provider to troubleshoot this error easily.
For example, if you use WordPress’s CDN enabler plugin, you can just deactivate the plugin and then test your website. The same goes with any other CDN plugin that you have hooked your CDN with, such as WP Rocket.
This issue can also occur with providers such as CloudFlare that provide fully proxy services or DDoS protection, as they have some extra firewalls in between. It is important to reach out to those providers and fix the error issue.
5. Verify your themes and plugins
Many a time, a bad code on your WordPress website from a third-party theme or plugin could be the reasons behind your queries and scripts being cancelled. Also, a lot of misconfigured caching plugins lead to the 502 eros generation.
You can resolve this issue by deactivating all your caching plugins. Do not worry about loss of data when you deactivate a plugin, as your data remains the same.
You can also reach out to and contact the plugin developer for support and help. Or you can go to the WordPress Repository and post a support ticket.
It is crucial to ensure that your themes and plugins are up to date. You might also need to contact and get help from the WordPress Developer to fix the issue if there is bad code in a plugin.
6. Check Logs
You must also take advantage and check your error logs to fix the 502 bad gateway issue. Your host provider must provide you with this option.
You can also monitor you logs for performance bottlenecks using Atatus Log Monitoring which provides intelligent insights about your Log events.
7. Restart Wordpress Site
This is another option that you can try, restarting Wordpress site, which quickly helps resolve the issue. If your hosting provider does not provide this option, you can open and raise a support ticket and request them to restart the PHP.
8. PHP Timeout Issue
PHP timeout issues are a common occurrence if you are implementing big WordPress Imports. A 502 error is generally displayed when this occurs.
You must contact your current WordPress host about the values set on your servers and ask them to increase those values if possible. The values also depend on your type of current hosting plan.
9. Contact your host provider
If none of the above-mentioned steps or solutions works for you, you must get in touch with your web host provider. Usually, these errors, such as the 502 error, occur because of an issue from the hosting provider. Sometimes a request, query, or script will take longer than usual, killing or cancelling the server. Most hosts, especially the shared hosts, implement a “kill script” that creates a bad gateway.
Another reason could be that your web host’s server is not reachable or is unavailable because of no connectivity or server downtimes. You must reach out to your web host in such situations, or you can also raise a support ticket or check your WordPress host’s status page.
Conclusion
Any error that takes your website down or makes it inaccessible to your users and customers is a serious threat to your WordPress website. It can negatively affect your businesses sales and search engine visibility.
There are several solutions to troubleshoot this issue and fix the 502 bad gateway error. Whether the problem is with your host or with your client-side, I hope the solutions mentioned above help you fix the issue and get your website up and running again.
Atatus: Complete Visibility Into Your WordPress Site
Do you want to know the performance bottlenecks in your WordPress Site?
You can monitor your WordPress site with Atatus and get in-depth insights about the performance and availability on how your site is performing. We also offer tools to monitor Application Performance, your entire Infrastructure and Logs.
#1 Solution for Logs, Traces & Metrics
APM
Kubernetes
Logs
Synthetics
RUM
Serverless
Security
More