ComputersSecurity

Error 502 Bad Gateway - what is it? Causes and solutions

Every Internet user saw a message in his browser "502: Bad Gateway", which means an error on the side of the web server during the processing of the request. Most often, the causes of failures are associated with improper configuration of the web server or equipment hosting company. The standard problem is incorrect processing of the DNS or proxy server.

What does "502: Bad Gateway" mean

The error indicates that the request to the web server from the browser side was received, but it was improperly processed or deleted from the general queue. If the server is located behind the Internet gateway, then the problem is probably in the gateway or in the operation of the web server itself, which transmits information about the error to the gateway, and it is then displayed in the user's browser.

Causes of Error 502. Lack of Server Resources

The most important problem with this error is the insufficient level of server resources for processing incoming requests, which causes the server to generate error 502. The lack of resources can be either hardware (lack of RAM, insufficient speed of the processor or disk), or software related to Incorrect configuration of the server or the software used.

But there is a situation where, with a sufficient level of resources, the server continues to periodically generate an error 502: Bad Gateway. What can it be, if not hardware failures?

Restriction of resources can be entered automatically when a dedicated VPS server or virtual hosting leaves the tariff plan. As a result, the server may not be able to cope with the current load.

Web servers, such as Apache, have a strictly defined number of request handlers that are specified when it is configured. If all of them are simultaneously occupied, the incoming request is placed in the queue, and its time can not exceed a minute for each of them. If the timeout is exceeded, the request is canceled and the user is given a 502 error. Additionally, the handler may simply not have enough current free resources for normal processing of the queue.

If you use PHP + FastCGI on the server, with an unoptimized number of php-cgi processes, there are almost always overloads and a lack of resources.

The most common reasons for the shortage of resources for processing requests

  1. The server can not cope with the current number of simultaneous site visitors. Also, a significant part of the resources can be spent by various search robots and incorrect software scripts.
  2. Server overload during hacker DDos attacks, when the server is brought to fault by a large number of simultaneous requests for processing.
  3. There may be a situation where, when using the virtual hosting service , Error 502: Bad Gateway unexpectedly occurs. What does it mean? This may indicate the presence of a problem on the hosting side, known as overselling, that is, placing the host on the same server as many client accounts as they lack the current hardware resources at peak times.
  4. Incorrect configuration of the server itself or lack of software or hardware compatibility.
  5. Use on the site of plug-in external resources, such as visit counters, various informers, scripts. An error can occur when there are problems with such external sources.
  6. Downloading large files to the server with poor Internet connection quality.

PHP script errors

Error 502 can occur because of scripts, plugins or extensions in PHP, which do not pass the appropriate code to the server when the execution is completed. For example, generate error 502: Bad Gateway nginx as one of the variants of the proxy server may due to incorrect detection of the script state and perception of a connection failure with the services of the web server as a system failure.

So, all the static information (pictures, site pages, Robots files) is loaded normally and without errors. What does "502: Bad Gateway" mean in this case? That a crash occurs when loading program scripts, plug-ins, and extensions.

Corrective Action 502

First of all, it is necessary to analyze the current server load, especially at the time of error. Particular attention should be paid to the loading of RAM and, if necessary, to increase its size to improve the processing of requests.

Verify the correct setting of the limits for the number of simultaneously processed php-cgi processes. Their incorrect configuration leads to a rapid overload of the service and the constant occurrence of the message "502: Bad Gateway". What is it and how to correctly set the limits of processes, check with the support service of the hosting provider.

Maximally reduce requests to external network resources and set the maximum time for their download and response. This will allow you to see what the server resources are going to, and help get rid of the external "slippage" of the site.

In case of suspicion of overselling or incorrect configuration of the server configuration, contact the host support service. If there is no reaction, and the problem will not be resolved, change the hosting provider. Inaccessibility of the server can lead to losses due to a simple error 502: Bad Gateway. What this means for business, I think, is not worth explaining.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.atomiyme.com. Theme powered by WordPress.