When you browse the web pages and access any links again, the message “502 Bad Gateway error” may appear on the screen instead of the site, and viewing the information posted on the site becomes impossible. The display of such a message most often means that problems have occurred on the proxy server, DNS server or hosting server where the site requested by the user is located.
In fact, displaying this message means that the browser has received an invalid type of response from the server, and the general screen saver “Bad Gateway – Error 502” appears on the computer display as an information about the situation. Apache Server may not have been able to process the request in time or may have done so incorrectly. If the server is running behind a gateway, the root of the problem may be in the gateway, or the Apache Server may be sending the Gateway a message about the problem.
WHAT COULD BE THE CAUSE OF THE 502 ERROR
The main problem causing the error is the lack of resources on the server computer, which leads to the message “502 Bad Gateway error”. Most often it happens due to lack of RAM on the computer. You can determine this by looking at the load level and the resources consumed in the manager. If the hosting tariff is exceeded, the restriction may be triggered and an error may appear. You can fix this by switching to a tariff with a large amount of computing power.
Apache Server is characterized by a rigid number of handlers fixed by the server configuration. If all handlers are busy, the request will get to the processing queue and wait no longer than 1 minute, and after the time has elapsed, “Error 502” will appear. In addition, the specifiers may not have enough resources to handle the requests properly.
WHAT THE USER SHOULD DO WHEN THE 502 ERROR APPEARS
First of all, you need to type the link of another guaranteed working resource in your browser, and thus check the availability of Internet access. If you have access and the error occurs again when accessing a particular resource, you should clear the cookies in your browser settings. If this manipulation did not help to fix the situation, then most likely the problem is on the server hosting the site.
HOW THE WEBMASTER FIXES “ERROR 502”
Analyze the level of the current load on the server and the load during an error. If there is a large load on the operative memory, it is necessary to increase its volume.
In case of constant code 502 it is necessary to check the correctness of setting the limit on the number of php-cgi processes, because their incorrect configuration will lead to permanent failure of the server.
Minimize the number of calls to external resources and set the limit for response time. These actions will help to monitor the “slippage” during downloads and identify server problems. For shared hosting sites, poor server configuration may be the cause of the error. In this case it is recommended to change your hosting service provider.