FAQ. Errors "502 Bad Gateway and 504 Gateway Time-out"

Материал из WiKi - UserSide
Версия от 20:36, 16 марта 2023; N.Skrypnik (обсуждение | вклад) (Новая страница: «en | ru During the operation, you may experience errors ''''502 Bad Gateway'''' and ''''504 Gateway Time-out'''': thumb|1200px|center thumb|1000px|center These errors are HTTP status codes, one of the standard server responses to a browser request. It is common...»)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)

en | ru

During the operation, you may experience errors '502 Bad Gateway' and '504 Gateway Time-out':

These errors are HTTP status codes, one of the standard server responses to a browser request.

It is common for these errors to occur when performing a request to retrieve the "List of connected ONUs/ONTs". The execution time depends on the number of ONUs on the OLT and can take up to 10 minutes. But it can also occur with other queries.

The main reason for the '502 Bad Gateway' and '504 Gateway Time-out' errors is insufficient time-out values.

If you get any of these errors, you should check your timeout settings. And change them to the correct values.

Here are some examples of how to change them:


1) php.ini и PHP-FPM Pool

  • The following commands modify the configuration files to increase the timeouts up to 180 seconds:
sudo sed -i "s@max_execution_time.*@max_execution_time = 180@" /etc/php/7.4/fpm/php.ini
sudo sed -i "s@max_input_time.*@max_input_time = 180@" /etc/php/7.4/fpm/php.ini
sudo sed -i 's@;request_terminate_timeout.*@request_terminate_timeout = 180@' /etc/php/7.4/fpm/pool.d/www.conf

sudo systemctl restart php7.4-fpm


After restarting the php-fpm service, check that the changes have taken effect.

This can be done on the USERSIDE page: Menu - Settings - Main - Various - phpinfo().



2) NGINX config

  • In the server configuration for userside for the location ~ \.php$ block, change the timeout value to 180 seconds and restart NGINX:
fastcgi_read_timeout = 180
sudo nginx -t && sudo nginx -s reload

* The default path is /etc/nginx/conf.d/default.conf (if the standard installation instructions were used). Edit the value in the required configuration file if you have more than one site on the server and have configured with this consideration.