504 gateway timeout issue during backup with nginx during update

Hello,

first of all thanks a lot for Nextcloud, I love you all.

I faced a small issue today during upgrade from NC 18.0.7 to 18.0.9, any time I tried the update from the web I received a 504 gateway time-out error.

Info
Nextcloud version : 18.0.7 Upgraded to 18.0.9:
Operating system : Debian bullseye
nginx version : 1.18.0
PHP version : 7.4

Here the logs from nginx

IP - - [12/Sep/2020:10:06:35 +0000] "POST /updater/index.php HTTP/1.1" 504 160 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0" "-" TLSv1.3/TLS_AES_256_GCM_SHA384
IP - - [12/Sep/2020:10:09:40 +0000] "POST /updater/index.php HTTP/1.1" 504 160 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0" "-" TLSv1.3/TLS_AES_256_GCM_SHA384

I noticed this in the error log:

2020/09/12 10:06:35 [error] 32098#32098: *763 upstream timed out (110: Connection timed out) while reading response header from upstream, client: IP, server: example.com, request: "POST /updater/index.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock", host: "example.com"
2020/09/12 10:09:40 [error] 32098#32098: *833 upstream timed out (110: Connection timed out) while reading response header from upstream, client: IP, server: example.com, request: "POST /updater/index.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock", host: "example.com"

Changing this in the default site inside the nextcloud location solved it.

    +++ b/nginx/sites-available/default
    @@ -242,6 +242,12 @@ server {
            fastcgi_pass unix:/run/php/php7.4-fpm.sock;
                 fastcgi_intercept_errors on;
                 fastcgi_request_buffering off;
    +
    +# TimeOUT backup time
    +fastcgi_read_timeout 180;

I saw the solution here: https://distinctplace.com/2017/04/22/nginx-upstream-timed-out/

At this time is working.

Anybody with a better solution?

Kind regards.

3 Likes

Thank you for sharing the solution, in my case I just needed to add proxy_read_timeout 600; to the server section of the nginx configuration to support upload of large files.