▷ Error 502 Bad Gateway: what it is, causes and solution

error 502 bad gateway

Error 502 Bad Gateway is, along with Error 401, one of the most common on the Internet. Facebook, Youtube, Twitter and pages built under WordPress and Prestashop show this type of error daily. The cause of it is usually related to a communication problem between the servers of the web page in question (incorrect gateway). The solution, as in previous errors seen in Tuexperto, varies depending on whether we are simple navigators of the page or if we are the administrators of the web. Whatever our case, the solution to Error 502 will not take us more than five minutes and some insistence in the case that we are the administrators and owners of the page.

What is Error 502 Bad Gateway and what causes it

As the name of the error indicates, Error 502 is due to a bad input of a certain response from one server to another. This bad input is due to the inability of one or more servers to communicate with the main web server. That is, the request made from our browser to the page's servers has not been able to be processed due to the lack of communication with the parent server .


By the very nature of the problem, the solution will generally come from the page owner. This does not mean that we cannot perform certain actions to solve the problem as simple users, since sometimes this can be caused by a browser cache or a certain proxy.

Solution to Error 502 Bad Gateway if we are users

There are several ways to solve the aforementioned error if we are navigators, and most are related to the Internet browser that we use.

Solution 1

The first thing we will have to do to solve Error 502 is to reload the page by pressing F5 to check that it is not a casual error. In the event that this error continues to be displayed, we will try to access another page on the same website to rule out a possible general website crash. For example, if we are at www.tuexperto.com/whatsapp, we will have to try to enter www.tuexperto.com.

Solution 2

In the event that the error continues to appear, the next thing we will have to do is clear the cache of the browser that we are using. In Google Chrome it is as simple as clicking on the three Options points, selecting More tools, clicking on Clear browsing data and finally clicking on Clear data .

clear cache google chrome

Is the web page still not showing? Then most likely it is a web error. We can try to enter from another device (mobile, tablet, laptop) through another WiFi or data connection to verify that this is the case.

Solution to Error 502 if we own the website

If we are administrators of the web page, the possible solution here varies depending on its origin and the type of web page.

Solution 1

In the event that we use WordPress as the CMS of our website, the first step to solve the error will be to disable the latest plugins and themes that we have installed on the web . If it is the case that we have installed many plugins recently, we can deactivate them all at once by changing the name of the Plugins folder in the wp-content folder of the page server.

disable wordpress plugins

The key at this point is to deactivate the plugins one by one and reload the page that is showing the error to see if it is solved, although this will depend on the number of plugins we have on our page.

Solution 2

If we have recently installed a CDN (Content Delivery Network) service to improve the loading speed of our website, it is likely that Error 502 was caused by it. This is because the code of the service in question may have conflicted with some of the code on our page.

Some of the main CDNs are as follows:

  • CloudFlare
  • Amazon CloudFront
  • MaxCDN
  • CDN77
  • Incapsula CDN
  • KeyCDN

To fix the gateway error, as simple as disabling the CDN through the service page temporarily . If we have found the solution, it is best to contact the service to solve this conflict.

Solution 3

Have we updated the website recently? Then it is likely that some error is being generated that conflicts with the communication between servers.

If we are advanced users, we can find the error in a very simple way. To do this, we will create a PHP file through an advanced text editor (NotePad ++) and introduce the following lines of code:

Original text

phpinfo (); ?> Next, we will copy the file to the root folder of the server and access it through the address www.domainname.com/filename.php . Once inside, we will look for the line that contains the error_log label  and we will find the path that the error refers to.

Solution 4

The last solution is to contact our hosting service to fix the error, since it may be due to a failure of the service server. If we have technical assistance, the most likely thing is that they will fix the error for free.

Other errors identified by OneExpert

  • Error 401 Authorization Required
  • HTTP error 500
  • Error 503 Service Temporal and Unavailable