Nginx - 504 Gateway Time-out - upstream timed out - Connection timed out

Autor Čolek
Publikováno 23.11.2020
Kategorie linux
Stav Vyřešeno
Dobrý den,

mám další problém s webserver Nginx na linux serveru. Při dlouhém importu mám chybu 504 Gateway Time-out. Prosím někoho o pomoc. Díky

CHYBA
------------------------
504 Gateway Time-out
nginx/1.18.0 (Ubuntu)


tail /var/log/nginx/error.log
------------------------

/var/run/php/php7.4-fpm.sock:", host: "192.168.17.2:8015", referrer: "http://192.168.17.2:8015/c/y"
2020/11/23 10:35:59 [error] 206255#206255: *22886 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.4.21, server: , request: "GET /admin-import/bike HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock", host: "192.168.17.2:8015", referrer: "http://192.168.17.2:8015/admin"


Odpovědi na dotaz 1

The English language is translated by machine - the translator can modify eg cited codes = it is better to use codes from the Czech original.

Nginx - 504 Gateway Time-out - upstream timed out - Connection timed out

Hi,

I have another problem with the Nginx webserver on the linux server. I'm getting a 504 Gateway Time-out error during a long import. I ask someone for help. Thanks

ERROR
------------------------
504 Gateway Time-out
nginx/1.18.0 (Ubuntu)


tail /var/log/nginx/error.log
------------------------

/var/run/php/php7.4-fpm.sock:", host: "192.168.17.2:8015", referrer: "http://192.168.17.2:8015/c/y"
2020/11/23 10:35:59 [error] 206255#206255: *22886 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.4.21, server: , request: "GET /admin-import/bike HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock", host: "192.168.17.2:8015", referrer: "http://192.168.17.2:8015/admin"

RE: Nginx - 504 Gateway Time-out - upstream timed out…

Autor Oxytocin
Publikováno 23.11.2020
Kategorie linux
Stav Zkontrolováno
Dobrý den,

upravte konfiguraci Nginx + PHP - je třeba navýšit limity, zkuste navýšit v php.ini max_execution_time a max_input_time, dále v nginx virtualhostu fastcgi_read_timeout takto:

vim /etc/php/7.4/fpm/php.ini

.................
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 300

; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; Note: This directive is hardcoded to -1 for the CLI SAPI
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
; http://php.net/max-input-time
max_input_time = 180
....................




vim /etc/nginx/sites-available/virtualhost.conf

server {
.................
fastcgi_buffers 16 32k;
fastcgi_buffer_size 64k;
fastcgi_busy_buffers_size 64k;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
fastcgi_read_timeout 180;
....................


systemctl reload nginx;systemctl restart php7.4-fpm



1

The English language is translated by machine - the translator can modify eg cited codes = it is better to use codes from the Czech original.

Nginx - 504 Gateway Time-out - upstream timed out - Connection timed out

Hello,

modify the configuration of Nginx + PHP - it is necessary to increase the limits, try to increase max_execution_time and max_input_time in php.ini, then in the nginx virtualhost fastcgi_read_timeout as follows:

vim /etc/php/7.4/fpm/php.ini

.................
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 300

; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; Note: This directive is hardcoded to -1 for the CLI SAPI
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
; http://php.net/max-input-time
max_input_time = 180
....................




vim /etc/nginx/sites-available/virtualhost.conf

server {
.................
fastcgi_buffers 16 32k;
fastcgi_buffer_size 64k;
fastcgi_busy_buffers_size 64k;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
fastcgi_read_timeout 180;
....................


systemctl reload nginx;systemctl restart php7.4-fpm


Tento web používá k poskytování služeb, personalizaci reklam a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tím souhlasíte. Další informace