How to Fix “upstream timed out (110: Connection timed out) while reading response header from upstream” in NGINX

Expected Behavior

NextCloud should install as expected on first run.

Current Behavior

Installation fails. Browser is posting: 504 Gateway Time-out. This is caused by the fact that the installation is very slow on some ARM devices so fastcgi/proxy times out.

Steps to Reproduce

Try to install NextCloud on a low-end ARM device.

Environment

OS: Debian 10
CPU architecture: arm64
How docker service was installed: From the distro’s repo.
Device: Odroid HC4
Extra OS info:

  • Linux version 5.11.0-odroid-arm64 (gcc-8 (Debian 8.3.0-6) 8.3.0, GNU ld (GNU Binutils for Debian) 2.31.1) SMP PREEMPT Debian 5.11.18-202108050550~buster (2021-08-04)
  • Docker version 18.09.1, build 4c52b90

Command used to create docker container (run/create/compose/screenshot)

docker-compose.yml file provided in the documentation.

Docker logs

[error] 412#412: *14 upstream timed out (110: Operation timed out) while reading response header from upstream, client: 10.11.12.1, server: _, request: "POST /index.php HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "cloud.rosca.info"

Recommended fix

Modify the config/nginx/site-confs/default file as follows. The new lines should be added in the location ~ \.php(?:$|/) section:

fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
fastcgi_connect_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

Confirmation

After making this change the installation got through without any issues.

Expected Behavior

NextCloud should install as expected on first run.

Current Behavior

Installation fails. Browser is posting: 504 Gateway Time-out. This is caused by the fact that the installation is very slow on some ARM devices so fastcgi/proxy times out.

Steps to Reproduce

Try to install NextCloud on a low-end ARM device.

Environment

OS: Debian 10
CPU architecture: arm64
How docker service was installed: From the distro’s repo.
Device: Odroid HC4
Extra OS info:

  • Linux version 5.11.0-odroid-arm64 (gcc-8 (Debian 8.3.0-6) 8.3.0, GNU ld (GNU Binutils for Debian) 2.31.1) SMP PREEMPT Debian 5.11.18-202108050550~buster (2021-08-04)
  • Docker version 18.09.1, build 4c52b90

Command used to create docker container (run/create/compose/screenshot)

docker-compose.yml file provided in the documentation.

Docker logs

[error] 412#412: *14 upstream timed out (110: Operation timed out) while reading response header from upstream, client: 10.11.12.1, server: _, request: "POST /index.php HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "cloud.rosca.info"

Recommended fix

Modify the config/nginx/site-confs/default file as follows. The new lines should be added in the location ~ \.php(?:$|/) section:

fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
fastcgi_connect_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

Confirmation

After making this change the installation got through without any issues.