13 September 2023

502 Bad Gateway Error on WordPress: A detailed guide to fix it

Explore the causes and solutions for the 502 Bad Gateway error in WordPress: a comprehensive guide to diagnosing and fixing this common problem, with step-by-step strategies for each scenario.

You are facing the age-old problem of error 502 Bad Gateway on your WordPress site and you don't know how to fix it? You're in the right place. This type of error is quite common in the WordPress community, but its diagnosis can turn into a real headache. The potential causes are numerous and vary from server overload to browser-related problems, through blocks set by the firewall or even incompatibility with themes and plugins.

The good news is that you don't have to worry. In this article, we will not only explore the most frequent causes behind error 502 in detail, but also guide you through a number of tested and reliable solutions. These strategies were designed to cover a wide range of problem scenarios; therefore, we recommend that you apply them one by one. This way, you will be able to precisely identify which solution is most effective in your specific case, allowing you to restore the normal functioning of your website as quickly as possible.

What is the 502 Bad Gateway Error on WordPress: Meaning, Causes and Variants

The 502 Bad Gateway error typically appears when you attempt to load a page or post on your WordPress site. Let's see what it means, why it occurs and what its variants are.

502 bad gateway nginx

What Does the 502 Bad Gateway Error Mean?

To understand the 502 error, you need to understand how loading a web page works. When you open a page, your browser sends a request to the site's server.

The server is where your WordPress site's files and folders are hosted.

Usually, the server responds by providing the content requested by the browser. However, sometimes, due to various reasons such as server overload, firewall blocks or browser problems, the server fails to serve the content. In these cases, the 502 Bad Gateway error appears.

What Causes the 502 Bad Gateway Error in WordPress?

The most common causes of the 502 error in WordPress include:

  • Server Overload: When the server receives too many requests, it can become overloaded and not respond correctly, resulting in a 502 error.
  • Browser problems: Outdated browsers or corrupt files in the browser cache can cause the error.
  • Firewall Blocking: The firewall installed on your site may be blocking your Internet Service Provider or your IP address, triggering the error.
  • Temporary server issues: The server may be temporarily down, causing the 502 error.

Variants of the 502 Bad Gateway Error

The 502 Bad Gateway error is a common problem that can manifest itself in a variety of ways, depending on the specifications of your web server, content management system, or customizations you've made to your site. Below, we explore the most common variations of this error in detail:

Error 502

This is the simplest and most generic form of the error. Usually, it appears when the server fails to get a valid response from another server. It doesn't provide specific details, making diagnosing the problem a little more complicated.


Similar to Error 502, this variant includes the “HTTP” protocol to indicate that the error is related to the hypertext transfer protocol. Again, the lack of additional details makes it difficult to identify the exact cause.

502 Proxy Error

This error is specific to cases where a proxy server is involved. Indicates that one of the two servers (the proxy or the origin server) returned an invalid or incomplete response. It is common in corporate environments or when using VPN services.

502 Bad Gateway

This is one of the most common forms of the error and indicates that one of the servers in the network location returned an invalid response. It is a generic message that does not provide details about the specific server causing the problem.

502 Bad Gateway NGINX

This variant indicates that the error was generated by a server that uses NGINX as its web server software. It is useful for narrowing the range of potential problems by focusing on the peculiarities of NGINX.

HTTP Error 502 Bad Gateway

This is a more descriptive form of the error, combining elements of the previous variants. Indicates that the error is related to the HTTP protocol and that one of the entities in the network path returned an invalid response.

502 Service Temporarily Overloaded

This variant suggests that the server is temporarily overloaded and cannot handle the request. It's a helpful indicator that the problem may resolve itself once the load on the server decreases.

502 Server Error: The server encountered a temporary error and could not complete your request

This is one of the most detailed descriptions of the 502 error. It indicates that the server encountered a temporary error and is unable to complete the request. It provides useful context to begin diagnosing the problem.

502 That's an error. The server encountered a temporary error and could not complete your request. Please try again in 30 seconds. That's all we know.

This variant is particularly frustrating because, while it provides a suggestion on how to proceed (“Try again in 30 seconds”), it offers no information on what the actual problem is.

Now that you have a clear understanding of what error 502 is, why it occurs, and its variations, let's move on to the solutions to remove it from your site.

How to Fix 502 Bad Gateway Error in WordPress

Dealing with the 502 error on WordPress can be a challenge, but there are several strategies you can employ to identify and resolve the issue. Here is a detailed guide on how to address each possible cause:

1. Reload Your Web Page

First of all, try reloading the web page. Sometimes, the 502 error can be the result of a small temporary glitch in the server or network, which resolves itself. Reloading the page is the quickest way to check if the problem has actually been resolved.

2. Clear your browser cache

The browser cache stores website data and resources to speed up future loads. However, if the cache is outdated or corrupt, it may display an incorrect version of the site, perpetuating the 502 error. Go to your browser settings and look for the option to clear the cache; then, restart your browser and try reloading the page.

Here's how to clear your browser cache in Chrome:

  1. Click on the three dots icon located in the top right corner.
  2. Expand the “More Tools” option in the drop-down menu.
  3. Select “Clear browsing data” in the list of options.
  4. Choose “All Periods” as the time range.
  5. Check the box for “Cached images and files” (and uncheck the other boxes).
  6. Click on the “Delete data” button.


3. Clear the DNS Cache

The Domain Name System, known as DNS, is a system that acts as a translator between the domain names we enter into the browser and the IP addresses of the servers on which the websites reside. Sometimes, the DNS cache can become stale or corrupt, directing your browser to the wrong IP address and causing errors like 502. To fix this problem, you can clear your operating system's DNS cache.

If you are using Windows, you can do this by opening the command prompt and typing the command “Ipconfig / flushdns“. If you are on a Mac, open the terminal and enter the command “dscacheutil -flushcache”. By running these commands, you will delete all previously stored DNS information, forcing the system to fetch new IP addresses, which may resolve the 502 error.

4. Check Hosting Server Issues

First of all, it is essential to check your hosting provider's dashboard or your email inbox to see if there are any notifications regarding service interruptions or scheduled maintenance. If your hosting is the cause of the error, the only thing you can do is wait for the problem to be resolved by the technical team.

However, if you don't find any notification or information that can explain the 502 error, another crucial step is to examine the server log files. These files, like error.log, they can provide valuable details about what might have gone wrong. Both the webserver (for example, Apache or NGINX) and the PHP interpreter generate these log files.

To access log files, you may need to enable the flag log_errors on in the PHP configuration file (php.ini). Once enabled, errors will be logged and you can review them to pinpoint specific issues.

If you are not familiar with systems engineering or development, reading log files may seem complicated. However, there are some indicators that can help you identify the cause of the problem. For example, a “Fatal Error” in the PHP log is a clear sign that there is an application level problem that needs further investigation.

Remember that understanding log files requires some familiarity with development and systems engineering. If you find terms or errors that you do not understand, it is advisable to contact your hosting provider's technical support, providing them with any information collected, including log file extracts, to speed up the process of diagnosing and resolving the problem.

5. Disable CDN and Firewall for Thorough Investigation

Content Delivery Network (CDN) services and firewalls play a crucial role in protecting and optimizing your website. However, these tools can sometimes interfere with the normal functioning of the site, generating false positives such as the 502 error. This is especially true for CDNs that operate as reverse proxies, such as CloudFlare. In this setup, web traffic passes through the CDN before reaching your server, which can make it difficult to pinpoint the exact cause of the error.

Pingora Reverse Proxy Scheme

To isolate the issue and conduct a more thorough investigation, it is advisable to temporarily disable both the CDN and the firewall. Once disabled, reload the page to see if the 502 error persists. If the error goes away, it is likely that one of these services is causing the problem.

In that case, you will need to carefully review your CDN and firewall settings to identify which rule or configuration may be responsible for the error. You may need to adjust some settings or, in extreme cases, consider switching to a different service that is more compatible with your specific setup.

Remember that disabling these services is a temporary measure to diagnose the problem. Once the cause of the 502 error has been identified and resolved, it is important to re-enable your CDN and firewall to maintain the performance and security of your website.

6. Update the PHP Version and Check Code Compatibility

Using an outdated version of PHP not only exposes your website to potential security risks, but can also be the cause of a variety of technical issues, including the appearance of the 502 error. However, the problem could also be opposite to: a version of PHP that is too recent may not yet be supported by some of your themes or plugins, causing incompatibilities and errors.

To update PHP, log in to your hosting control panel and look for the option to update your PHP version. This option is usually available in the server or programming language settings section. If you are unsure how to proceed, please do not hesitate to contact your hosting provider's technical support for assistance.

Once you've updated your PHP version, it's crucial to test all the features of your website to make sure everything is working as expected. If you encounter problems or incompatibilities, you may need to update or replace themes and plugins that are not compatible with the new version of PHP. In some cases, you may also need to examine your custom code to identify and fix any compatibility issues.

If you are still experiencing the 502 error after upgrading, please consider rolling back to the previous version of PHP and contact technical support for further investigation. In any case, keeping your PHP version updated is a recommended practice to ensure optimal performance and security of your website.

7. Check Themes and Plugins: A Task for Experienced WordPress Developers

Themes and plugins are fundamental components of any WordPress site, but they can also be the source of various problems, including the appearance of the 502 error. These components can conflict with each other or with the WordPress core, making the diagnosis and Problem solving is a complex activity that requires some experience.

Although it is possible Perform a basic check by disabling all themes and plugins and then re-enabling them one at a time, this task is best delegated to an experienced WordPress developer. A professional will have the expertise to also examine log files, interpret PHP errors, and understand the complex interactions between the various components of your site.

To get started, disable all themes and plugins through your WordPress dashboard or directly via FTP. Subsequently, reactivate them one at a time, reloading the site page after each activation. This will allow you to identify which theme or plugin is causing the error. Once you find the culprit, you may need to update, fix, or replace it.

Please note that some themes and plugins may have cross-dependencies, and disabling one may affect the functioning of the others. Furthermore, some advanced features like page builders or caching plugins can further complicate the situation.

For all these reasons, if you are not an expert in WordPress or web development, it is highly advisable to delegate this task to an experienced WordPress developer. He or she will be able to perform a more accurate diagnosis and may even be able to correct the problematic code directly, thus solving the problem more efficiently and permanently.

8. Contact Your Hosting Provider: The Last Resort for a Quick and Effective Solution

If, despite all the efforts and troubleshooting procedures you have followed, the 502 error continues to plague your website, it is time to consult the experts: your hosting provider's technical support team. These professionals have the experience and tools necessary to diagnose and solve complex problems that may be beyond your capabilities.

Before contacting support, be sure to gather all relevant information regarding the actions you have already taken to resolve the issue. This includes details about any recent changes made to the site, themes or plugins that you've identified as potential culprits, and any other data that might be useful, such as extracts from server log files or specific error messages. Providing a complete picture of the situation will not only speed up the diagnosis process, but also allow the support team to provide a more targeted and effective solution.

Also, if you have already performed operations such as clearing the cache, updating PHP, or disabling CDN and firewall, please note this information as well. This will prevent technical support from repeating steps you have already performed, thus optimizing the time to resolve the problem.

Remember that your hosting's technical support is a valuable resource, especially in critical situations like this. Don't hesitate to use this option as a last resort to get your website back to normal as quickly as possible.


Dealing with an error like the 502 Bad Gateway can be not only stressful but also technically complex. If you find yourself in this difficult situation and can't find a solution, our team of Linux systems engineers and WordPress developers is ready to assist you, with the promise of solving the problem in less than an hour.

As part of our Managed Hosting services, we offer a level of support that goes far beyond simple hosting. In addition to ensuring your site is always up and running and optimized, our team is highly trained to tackle advanced technical issues. These can include tasks such as specific debugging to control the size of web server buffers, optimization of database queries, and many other technicalities that are within the reach of only experienced systems engineers.

These types of advanced problems require deep technical knowledge and a detailed understanding of the underlying mechanisms that power your website. That's why it's crucial to rely on a team of experts who can not only identify but also solve these complex problems quickly and effectively.

If your website is showing 502 Bad Gateway error and you are stuck for solutions, don't hesitate to contact us. With our experience and expertise, we can guarantee an accurate diagnosis and a quick solution to get your site back to normal.

Do you have doubts? Don't know where to start? Contact us!

We have all the answers to your questions to help you make the right choice.

Chat with us

Chat directly with our presales support.


Contact us by phone during office hours 9:30 - 19:30

Contact us online

Open a request directly in the contact area.


Managed Server Srl is a leading Italian player in providing advanced GNU/Linux system solutions oriented towards high performance. With a low-cost and predictable subscription model, we ensure that our customers have access to advanced technologies in hosting, dedicated servers and cloud services. In addition to this, we offer systems consultancy on Linux systems and specialized maintenance in DBMS, IT Security, Cloud and much more. We stand out for our expertise in hosting leading Open Source CMS such as WordPress, WooCommerce, Drupal, Prestashop, Joomla, OpenCart and Magento, supported by a high-level support and consultancy service suitable for Public Administration, SMEs and any size.

Red Hat, Inc. owns the rights to Red Hat®, RHEL®, RedHat Linux®, and CentOS®; AlmaLinux™ is a trademark of AlmaLinux OS Foundation; Rocky Linux® is a registered trademark of the Rocky Linux Foundation; SUSE® is a registered trademark of SUSE LLC; Canonical Ltd. owns the rights to Ubuntu®; Software in the Public Interest, Inc. holds the rights to Debian®; Linus Torvalds holds the rights to Linux®; FreeBSD® is a registered trademark of The FreeBSD Foundation; NetBSD® is a registered trademark of The NetBSD Foundation; OpenBSD® is a registered trademark of Theo de Raadt. Oracle Corporation owns the rights to Oracle®, MySQL®, and MyRocks®; Percona® is a registered trademark of Percona LLC; MariaDB® is a registered trademark of MariaDB Corporation Ab; REDIS® is a registered trademark of Redis Labs Ltd. F5 Networks, Inc. owns the rights to NGINX® and NGINX Plus®; Varnish® is a registered trademark of Varnish Software AB. Adobe Inc. holds the rights to Magento®; PrestaShop® is a registered trademark of PrestaShop SA; OpenCart® is a registered trademark of OpenCart Limited. Automattic Inc. owns the rights to WordPress®, WooCommerce®, and JetPack®; Open Source Matters, Inc. owns the rights to Joomla®; Dries Buytaert holds the rights to Drupal®. Amazon Web Services, Inc. holds the rights to AWS®; Google LLC holds the rights to Google Cloud™ and Chrome™; Microsoft Corporation holds the rights to Microsoft®, Azure®, and Internet Explorer®; Mozilla Foundation owns the rights to Firefox®. Apache® is a registered trademark of The Apache Software Foundation; PHP® is a registered trademark of the PHP Group. CloudFlare® is a registered trademark of Cloudflare, Inc.; NETSCOUT® is a registered trademark of NETSCOUT Systems Inc.; ElasticSearch®, LogStash®, and Kibana® are registered trademarks of Elastic NV Hetzner Online GmbH owns the rights to Hetzner®; OVHcloud is a registered trademark of OVH Groupe SAS; cPanel®, LLC owns the rights to cPanel®; Plesk® is a registered trademark of Plesk International GmbH; Facebook, Inc. owns the rights to Facebook®. This site is not affiliated, sponsored or otherwise associated with any of the entities mentioned above and does not represent any of these entities in any way. All rights to the brands and product names mentioned are the property of their respective copyright holders. Any other trademarks mentioned belong to their registrants. MANAGED SERVER® is a trademark registered at European level by MANAGED SERVER SRL, Via Enzo Ferrari, 9, 62012 Civitanova Marche (MC), Italy.


Would you like to see how your WooCommerce runs on our systems without having to migrate anything? 

Enter the address of your WooCommerce site and you will get a navigable demonstration, without having to do absolutely anything and completely free.

No thanks, my customers prefer the slow site.
Back to top