Error 502 Bad Gateway nginx and why does it occur?

If this error occurs, then HTTP requests from clients to your site are going through some kind of gateway. For example, if the hosting in front of the Apache web server is the nginx web server, then nginx will be the gateway.

The 502nd error means that the request from the client went through nginx, got to Apache, and Apache could not process the request, as reported to nginx. As a result, nginx sends an error to the client.


Cause of error 502 Bad Gateway:

Server software timeout. A 502 error is inevitable when nginx slows down when a caching facility (such as Varnish Cache) times out. This also includes slow queries;

Server overload. The web server may crash due to a lack of resources (for example, RAM, insufficient processor or disk speed), caused by an excess of running processes or aggressive user actions;

Bad site code. Sites with outdated CMS, plugins or clumsy code affect the proper functioning of the server and lead to periodic 502 errors;

Network errors. Other network configuration errors (problems with DNS, routing, blocking by a firewall used on the server, problems with the provider) also cause a 502 server error to appear;

Frequent reboot of the web server. This happens with configuration errors, module failures, any attacks, excess running processes and applications. As a result, the user sees a temporary 502 error;

Uploading large files to the server with poor quality Internet connection;

 

Here are some tips on how to fix the 502 bad gateway error:

Make sure that the site files (plugins and themes) are timely updated and not out of date;

Audit server software and update modules on time;

Avoid routing issues and track any server congestion / attacks;

Optimize and fix slow MySQL queries;

Disable scripts for monitoring and tracking visitors on the site, because every movement of your customers on the site makes a query to the database;

Disable all internal statistics on the site - for example, use http://www.google.com/analytics;

You can log into phpMyAdmin and check which tables have the most records. After that, if you see that a certain table does not contain valuable information, but simply contains logs, statistics, cache, then you can clear or delete it.

  • 52 Пользователей нашли это полезным
Помог ли вам данный ответ?

Статьи по Теме

Помогите, я не могу установить компоненты Joomla!

Это известная проблема Joomla, когда компоненты не могут быть установлены через окно браузера....

Помогите, я удалил файлы.

Бэкапы автоматически создаются еженедельно на Премиум тарифе и ежедневно на Бизнес плане. Вы...

Где можно посмотреть CPU логи процессора?

Наш хостинг не хранит логи CPU использования процессора на данный момент. Когда учётная запись...

Я не могу войти на сайт, он не работает. Что делать?

Иногда Ваш сайт может стать недоступным и он может не отобразится для Вас. Ниже перечислены...

Команда пинг ping и tracert(traceroute) как правильно использовать?

Команда ping используется для проверки доступности сетевых ресурсов. Чаще всего она нужна, чтобы...