{ "@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [ { "@type": "Question", "name": "Que signifie "Bad Gateway" en français ?", "acceptedAnswer": { "@type": "Answer", "text": ""Bad Gateway" se traduit littéralement par mauvaise passerelle en français. Concrètement, la signification du code 502 Bad Gateway est la suivante : un serveur intermédiaire (proxy, load balancer ou CDN) a reçu une réponse invalide ou incomplète de la part du serveur en amont. Autrement dit, votre site n'est pas directement en cause : c'est la communication entre deux serveurs qui a échoué." } }, { "@type": "Question", "name": "Quelle est la différence entre l'erreur 502 et les erreurs 500, 503, 504 ?", "acceptedAnswer": { "@type": "Answer", "text": "Ces codes HTTP sont tous des erreurs serveur, mais ils n'ont pas la même origine. L'erreur 500 (Internal Server Error) signale un problème générique côté serveur, tandis que le 502 Bad Gateway indique une réponse invalide reçue par un serveur intermédiaire. Le 503 (Service Unavailable) signifie que le serveur est temporairement indisponible (surcharge ou maintenance), et le 504 (Gateway Timeout) survient lorsque le serveur intermédiaire n'obtient pas de réponse dans les délais impartis. En résumé : 502 = mauvaise réponse, 504 = pas de réponse du tout." } }, { "@type": "Question", "name": "Pourquoi mon site WordPress affiche-t-il une erreur 502 Bad Gateway ?", "acceptedAnswer": { "@type": "Answer", "text": "Une erreur 502 Bad Gateway sur WordPress survient généralement lorsque le serveur PHP (PHP-FPM) plante ou est surchargé, lorsqu'un proxy inverse (Nginx, Cloudflare, Varnish) ne parvient pas à joindre le backend, ou encore lors d'un pic de trafic qui épuise les ressources disponibles. Des plugins mal configurés, une limite mémoire PHP trop basse ou un processus WordPress bloqué peuvent également déclencher cette erreur. Dans la plupart des cas, le problème est temporaire et lié à l'infrastructure d'hébergement." } }, { "@type": "Question", "name": "Comment corriger rapidement une erreur 502 Bad Gateway sur WordPress ?", "acceptedAnswer": { "@type": "Answer", "text": "Commencez par recharger la page après 30 secondes : une surcharge passagère se résout souvent d'elle-même. Si l'erreur persiste, videz le cache de votre navigateur et celui de votre plugin de cache WordPress, puis vérifiez l'état de votre hébergeur. Désactivez temporairement vos plugins (via FTP si l'admin est inaccessible) pour isoler un éventuel conflit. Si rien ne change, contactez votre hébergeur : il dispose des logs serveur nécessaires pour identifier la cause exacte du 502 Bad Gateway." } }, { "@type": "Question", "name": "Comment résoudre l'erreur 502 Bad Gateway sur Nginx avec WordPress ?", "acceptedAnswer": { "@type": "Answer", "text": "Sur une configuration Bad Gateway Nginx WordPress, l'erreur provient le plus souvent d'un problème de communication entre Nginx et PHP-FPM. Vérifiez que le service PHP-FPM est bien démarré (systemctl status php-fpm) et que le socket ou le port configuré dans le bloc fastcgi_pass de Nginx correspond bien à celui écouté par PHP-FPM. Augmentez si nécessaire les valeurs fastcgi_read_timeout et fastcgi_connect_timeout dans la configuration Nginx. Un redémarrage des deux services (nginx et php-fpm) suffit souvent à corriger le 502 bad gateway nginx." } }, { "@type": "Question", "name": "L'erreur 502 vient-elle de mon hébergeur ou de mon site WordPress ?", "acceptedAnswer": { "@type": "Answer", "text": "Dans la majorité des cas, une erreur 502 Bad Gateway est liée à l'infrastructure d'hébergement plutôt qu'au code de votre site WordPress. Elle peut provenir d'un proxy intermédiaire (comme Cloudflare ou un load balancer), d'un serveur PHP surchargé chez votre hébergeur, ou d'un problème réseau entre deux couches serveur. Cela dit, un plugin générant des requêtes excessives ou une configuration PHP défaillante (502 bad gateway php) peuvent aussi en être la cause côté site. La consultation des logs serveur permet de trancher rapidement." } }, { "@type": "Question", "name": "L'erreur 502 Bad Gateway peut-elle être causée par un plugin WordPress ?", "acceptedAnswer": { "@type": "Answer", "text": "Oui, certains plugins peuvent indirectement provoquer une erreur 502 Bad Gateway en générant des requêtes très lourdes, en consommant trop de mémoire PHP ou en déclenchant des timeouts. C'est notamment le cas de plugins de cache mal configurés, de constructeurs de pages gourmands en ressources ou de plugins d'import/export traitant de gros volumes de données. Pour le vérifier, désactivez tous vos plugins puis réactivez-les un par un jusqu'à identifier le fautif." } }, { "@type": "Question", "name": "Comment éviter les erreurs 502 sur WordPress à l'avenir ?", "acceptedAnswer": { "@type": "Answer", "text": "Pour prévenir les erreurs 502 Bad Gateway, veillez à choisir un hébergement dimensionné pour votre trafic et à maintenir WordPress, vos thèmes et vos plugins à jour. Configurez un système de monitoring (UptimeRobot, Jetpack Monitor) pour être alerté immédiatement en cas de panne. Limitez le nombre de plugins actifs, optimisez vos requêtes en base de données et mettez en place un cache performant pour réduire la charge serveur. En cas de 502 proxy error récurrent, un audit technique de votre hébergement s'impose." } } ] }

Publié le Mis à jour le 20 min de lecture

Error 502, 502 Bad Gateway: in fact, whatever it says, it doesn’t really matter. When this kind of message appears on a page on your screen, no translation is needed. 

The damage is already done. And you quickly understand that there’s a problem. The screen is (almost) completely white. You can’t view the page content. In short, you’re facing a 502 error.

It’s the kind of error every webmaster hopes not to encounter too often. When it occurs, it’s best to fix it as quickly as possible. 

By the end of this article, you’ll be able to fix a 502 error on WordPress using 8 concrete, practical solutions. 

And if that doesn’t solve your problem, don’t hesitate to contact our WordPress agency.

What is a 502 error?

Definition of a 502 error

HTTP 502 error, commonly called 502 Bad Gateway, is a server-side error.
When it occurs, the server cannot respond to a request sent by your web browser: an error message then appears on your screen. The page or article you want to view is unavailable and does not display.

In its official documentation, the Mozilla browser states that in the case of a 502 error, “the server, while acting as a gateway or proxy, received an invalid response from the upstream server”.

In practice, here is what happens, in order, when you encounter a 502 error: 

  1. You want to access a web page, either by typing its URL (web address) into the search bar of your favorite browser, or by clicking on a link.
  2. Your browser sends a request to your site’s hosting server web. In simple terms, it asks whether it is able to display the page.
  3. If all goes well, the server processes the request and displays the content of the web page. It then returns a successful HTTP response code (code 200). You don’t see it on the screen; everything happens in the background.
  4. If there is a problem, a server error HTTP response code is displayed on the screen: the famous Bad Gateway. 
The 502 Bad Gateway error in WordPress.
Source: Mozilla.

What are the other types of server errors?

The 502 error belongs to the family of server errors (HTTP response codes from 500 to 599). Among them, for example, are: 

  • the 500 error (Internal Server Error): the server encountered a situation it does not know how to handle;
  • the 501 error (Not Implemented): the server does not support the request method;
  • error 503 (Service Unavailable), when the server is not ready to process the request (it is unavailable or under maintenance); 
  • error 504 (Gateway Timeout): the server was unable to provide a response in time;
  • error 505 (HTTP Version Not Supported): the server is unable to support the version of HTTP used in the request.

Beyond that, you will also sometimes encounter:

  • HTTP client errors (your web browser), such as error 404 (page unavailable);
Part of Maintenance WP’s 404 page.
Part of Maintenance WP’s 404 page.
  • redirection errors, such as the 301 redirection response status code. It indicates that a page has been permanently moved to another URL.

Error 502 is not limited to WordPress. You may encounter it on other CMS (Content Management System) platforms such as Shopify, Squarespace, Wix, Drupal, Joomla, etc. But you may also encounter a 502 error on Google, or on any web server unable to forward a request to access a website.

How can a 502 bad gateway error appear on screen?

On your screen, the visual appearance of a 502 error can take different forms. For example, it may be displayed like this:

Display of a 502 error on the screen.
Source: Kinsta blog.

However, variations are possible, first of all in terms of form. Some hosting providers may customize its appearance to make it less austere. 

Next, the wording that appears on the screen may come in different variants, with terms most often in English. Here is a non-exhaustive list: 

  • Temporary Error (502) or Temporary Error (502);
  • 502 Error;
  • HTTP Error 502;
  • 502 Server Error; 
  • Error 502;
  • 502 Service temporarily overloaded;
  • Error 502 proxy error or 502 Proxy Error;
  • HTTP Error 502 Bad Gateway;
  • 502 Bad Gateway Nginx;
  • HTTP Error 502 Bad Gateway;
  • 502 Service Temporarily Overloaded;
  • 502 Server Error: The server encountered a temporary error and could not complete your request.

What are the causes and consequences of a 502 error on WordPress?

What causes a 502 error?

Like most server-side errors, the 502 error provides very little information about why it occurred. From experience, however, we know that it can be caused by different types of factors: 

  • incorrect server configuration. This may involve problems related to the configuration of the proxy server, the PHP server, or the configuration of the web server configuration files;
  • a lack of resources at the hosting server level. If it is too overloaded, for example due to a traffic spike on your website, it will not be able to process the request sent by your browser. It will crash and display a 502 error; 
  • a general server outage; 
  • errors in your web browser when displaying a web page; 
  • the presence of corrupted files or security vulnerabilities within your plugins or your WordPress theme; 
  • an incompatibility between plugins or themes after a recent installation or an update;
  • a security issue on WordPress due, for example, to a DDoS attack (Distributed Denial of Service).

What is the impact of a 502 error on your WordPress site?

When it occurs, an HTTP 502 error can have negative consequences for your WordPress site, and more broadly for your online business. 

If this error is not resolved quickly, you risk:

  • damaging the user experience (UX), because your visitors will not be able to access your website content and find an answer or solution to their problem.
    If the error occurs too often, they may turn away from your site and go to your competitors; 
  • damaging your brand image. An unavailable website conveys an unprofessional image and may indicate a lack of reliability. You will appear less credible in the eyes of internet users.
  • experience a drop in traffic. If Google’s bots repeatedly encounter 502 errors on your website, this can slow down the crawling of your pages and negatively impact your organic SEO. In addition, Google could remove the URLs of your affected pages from its index, which would lead to a significant drop in your visibility in search results.
  • see your conversion rate drop. Visitors who cannot access your pages will not be able to complete the desired actions, such as purchasing a product, filling out a form, or subscribing to your newsletter. This can have a significant impact on your revenue.
  • notice that some transactions are canceled. If you have a WooCommerce online store, for example, any payment transaction may be canceled if a 502 error occurs at the same time. 

Unfortunately, a 502 error is inherently uncontrollable: there is no way to know when it will appear on your screen.

However, there are solutions to fix it if you ever have to deal with it. Find all our detailed explanations in the next section. 

How to fix the 502 Bad Gateway error: 8 solutions

To begin, we recommend backing up your site before proceeding with technical troubleshooting. To do this, you can use a backup plugin like UpdraftPlus, or a maintenance tool like WP Umbrella. Whichever solution you choose, back up both your site files and its database.
If a problem occurs later, you will be able to easily restore your WordPress site. 

Reload the page

Before diving into the source code of your WordPress website, see whether a small, very simple action can make the 502 error disappear. 

Go to the “faulty” web page and reload it. To do this, press the F5 key on your keyboard, or click your web browser’s “refresh” icon:

Refreshing the page can help fix a 502 error.

If nothing happens immediately after this, wait a few minutes, then repeat the process again.

The server may have had a slight overload due to a spike in traffic. Giving it a few moments to catch its breath and recover can work. 

There is also nothing stopping you from trying the following tips at the same time: 

  • try displaying the page in another browser. For example, if you are using Google Chrome, see whether that famous 502 Bad Gateway code also appears in Mozilla or Safari. If it does not, Chrome is probably to blame, for example through one of its extensions (an ad blocker you installed could be the culprit). 
  • use a tool to find out whether the website you want to visit is down for everyone, or whether the problem is on your end. You can try Down for Everyone or Just Me or Is It Down Right Now. 
The Down for Everyone or Just Me site lets you find out whether a 502 error is affecting everyone or just you.

Clear your browser cache to fix a 502 error

The previous tip did not work? Let’s move on to the next solution, which is to clear your web browser’s cache.

To display a web page to a visitor as quickly as possible, a web browser caches it — basically, it keeps it in memory — after a first visit. This allows it to serve you a copy of the original page without having to download it again from the origin server.

It is an effective process. However, a 502 error will persist on the screen if the page is still cached, even though the server is no longer experiencing any problems. 

To resolve this issue, clear your browser cache. Here is the method used on the Google Chrome browser, the most widely used by Internet users in France (the process is the same for competing browsers):

  1. Click on the 3 small dots at the top of the toolbar, on the right. 
  2. Choose More tools > Clear browsing data. A pop-up window will open in the foreground.
  3. In the “General” tab, choose a time range (hours, days, weeks, or all data) and check the “Cached images and files” box.
  4. Click “Clear data” to clear the cache.
Clearing a web browser’s cache can fix a 502 error.

Is the 502 error still there? Read on. 

Disable your plugins

Like any webmaster or WordPress user, you use plugins to add new features to your site. 

It must be said that they are very useful, for example to strengthen your site’s security. Yes, but here’s the thing: sometimes, WordPress plugins can cause a 502 error.

This can appear after an update, due to an incompatibility or a problem in the PHP code.

To resolve it, you will need to find the culprit plugin by disabling all the plugins on your site. 

Since your site may be inaccessible (making it impossible to log in to the admin area), you will need to go through either: 

  • an FTP client such as Filezilla (free);
  • the administration interface provided by your hosting provider. One of the best known is called cPanel. 

Here is the procedure to follow with FileZilla.

Rename the plugins directory to resolve a 502 error

Log in to FileZilla using the credentials provided by your hosting provider (username, password, and host).

Go to your site’s root folder (e.g., public_html), then navigate to wp-content > plugins. Change the name of this directory and recreate a new plugins folder (e.g., plugins-erreurs): 

The wp-content folder contains, among other things, the plugins of a WordPress site.

Reactivate your plugins one by one

WordPress will deactivate all your plugins. Is your website working again? Then a plugin is indeed the culprit. 

If possible, log in to your site and reactivate your plugins one by one. Each time, remember to refresh your page.

When you find the plugin at fault, you have two options: 

  • delete it permanently and replace it with an alternative plugin; 
  • deactivate it until its developer releases a fix.

Finally, once all your plugins have been reactivated, don’t forget to delete the plugins-erreur folder from your FTP. 

If this solution still hasn’t worked, your theme may be the cause.

Check whether your theme is causing the 502 error

To deactivate your theme, the process is the same as for your WordPress plugins. Only access to their directory changes. In detail, here is how to do it in your FTP client: 

  • go to the wp-content > themes folder; 
  • download the folder of your active theme by right-clicking and selecting  “Download”. 
  • delete the theme you just downloaded (right-click > Delete).
Deleting a theme via FTP can help resolve a 502 error on WordPress.

Go back to your web browser and reload the page where the 502 error was displayed. If your theme was the cause, the error will have disappeared. In the meantime, WordPress will have activated one of its default themes (e.g., Twenty Twenty-Three).

If it doesn’t suit you, activate the theme you want (Astra, Kadence, Blocksy or GeneratePress are excellent choices). 

Does the 502 error persist? Reinstall your theme, the one you previously downloaded to your computer, by uploading it to your FTP. Then move on to the next solution. 

Deactivate your CDN and/or your firewall

Are you using a CDN on your WordPress site (for example via the WP Rocket cache plugin)? If so, deactivate it to see whether it changes anything on the screen.

CDN (Content Delivery Network) stands for Content Delivery Network. It is a group of interconnected servers located in different places around the world. These servers cache pages that do not need to be updated regularly and serve them to users more quickly by using the servers located closest to them. 

As for the procedure to follow, it all depends on the service you use (Cloudflare, KeyCDN, RocketCDN, Bunny.net, etc.). Check its documentation to find out more.

Is the 502 error still causing trouble? In that case, you should check your firewall. 

This is a tool capable of blocking malicious requests from your web server. Many WordPress security plugins offer this option. This is the case, for example, with one of the most famous of them, Wordfence Security. 

To disable its application firewall, go to Wordfence > Firewall in your WordPress back office. In the “Web Application Firewall Status” menu, click the drop-down menu and choose the “Disabled” option (“Disabled”):

Disabling the Wordfence Security firewall.

Finish by saving your changes, then reload your page. If the 502 error has disappeared, you have fixed the problem.

Otherwise, enable the firewall again to continue protecting your site. Let’s continue our investigation by taking a look at the logs. 

Check your server logs

Logs are text files that record events that have occurred on your server. Access to these files is available through the interface of some hosting providers. Contact yours to see whether this is the case.

Alternatively, you can view these files using your FTP client or the file manager provided by your hosting provider (e.g., cPanel).

If a log file is already present in the root directory of your site, it will appear, for example, in this form: error.log. If you don’t have one, enable WordPress debug mode to display it.

Whenever possible, carry out this operation in a test environment (locally or on a staging site). Avoid doing this on production sites, in case your sites crash. To create a local site, we recommend the DevKinsta tool or Local. For a staging site, you can activate the WP Staging plugin or use this service through your web host, if they offer it. 

To do this, access your wp-config.php file, located at the root of your site. Then manually replace the value “false” with “true”, as on the line below:

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

If errors are detected, they will appear in a log file called debug.log. You will find it in wp-content > debug.log.

If you need to display your errors on screen, set the constant  'WP_DEBUG_DISPLAY’ to the value true. 

Finally, don’t forget to set 'WP_DEBUG' back to false at the end of the process.

Change your PHP version

In WordPress jargon, WP_DEBUG is what is known as a PHP constant (the scripting language in which a large part of WordPress’s source code is written).

Speaking of PHP, let’s continue with it. When updating to a major version of WordPress, or simply installing new plugins, a 502 Bad Gateway error may have cropped up. 

Under the hood, your site’s new configuration may no longer be compatible with the version of PHP you are using. 

A version of PHP that is too outdated will prevent certain scripts or plugins from working properly. Hence the appearance of a 502 error.

For security and performance reasons, it is recommended to use one of the latest versions of PHP.

You can update it in just a few clicks from your hosting provider’s interface. But just before that, follow the recommendations in the official WordPress documentation: 

  • back up your site; 
  • update WordPress core, your themes, and plugins; 
  • check your site’s compatibility with the PHP version you want to use with the PHP Compatibility Checker plugin. 

When you are ready, log in to your cPanel (or a similar interface provided by your hosting provider) and follow these two steps:

  1. In the “Software” section, click “Select PHP Version”.  
  2. From the drop-down menu, select the PHP version you are interested in. At the time of writing, WordPress recommended a PHP version of at least 7.4. We recommend, if your site’s compatibility allows it, switching to at least PHP 8.0. 
Updating the PHP version to fix a 502 error on WordPress.

For greater peace of mind, test the new PHP version you want to enable on your site in a test environment. With KinstaDev or Local, you can choose the PHP version of your choice as soon as you create a new instance. If you don’t encounter any issues, you can make the switch to production with complete confidence.  

Contact your hosting provider

Have all the solutions listed so far not worked for you? You may still be able to resolve this 502 error by contacting your hosting provider’s support team. 

Clearly explain to them the situation you are experiencing and the steps you have taken so far to try to fix the error. 

With a bit of luck, your hosting provider’s server may be the cause. The technical team will then take care of resolving the issue. On your side, all you will have to do is wait.

If that is not the case, ask support if they can increase the PHP execution time, that is, the maximum amount of time a PHP script can run. This technical measure can help you get rid of a recurring 502 error.

Summary

Thanks to this article, you now have an overview of the 502 error on WordPress. In summary, throughout these lines you have discovered in particular: 

  • what a 502 error is; 
  • what its variants are; 
  • what its causes and consequences are;
  • 8 practical solutions to resolve it.

If you ever have to deal with this server error one day, don’t waste any time fixing it. As you’ve seen, the longer you wait, the more negative the consequences can be in terms of SEO, brand image, and revenue.

Would you like support in implementing our various tips to resolve a 502 error?

Available 7 days a week, our WordPress support service will offer you a tailor-made solution that meets your needs quickly, professionally, and effectively.

Découvrez plus de contenus

fleche separateur

Voir plus d’articles