Sync connection time out-- Nextcloud + nginx on Raspberry Pi

I’ve recently installed Nextcloud on a Raspberry Pi running nginx. I’ve been running into problems doing the initial big sync of files from my computer. The Nextcloud client runs well for about 20 minutes, then stops working. I get a “Connection Timeout” error, no more files upload, and I have to reboot the Pi to get it to start again.

Since the Pi has such limited resources, I imagine that something is filling up, running over, or taking longer than it might on another machine. I see various errors in the nginx and php5-fpm logs, but I’m having trouble understanding where the failure is actually happening. I’m especially getting lost in the chain of connections from nginx to fastCGI to php5-fpm. I’ve tried adjusting various connection times, buffer sizes and max child process numbers, but without understanding which thing is overrunning, I can’t tell which actually needs adjustment.

Here are some example errors:

From nginx.log:

2017/02/09 23:11:16 [error] 2639#2639: *527 upstream timed out (110: Connection timed out) while reading response header from upstream, client: XX.XXX.XXX.XXX, server: XXXXX, request: “PUT /remote.php/webdav/FILE HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php5-fpm.sock”, host: “XXXX.XXXX.XXX"
2017/02/09 23:12:34 [error] 2639#2639: *527 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: XX.XXX.XXX.XXX, server: XXXXX, request: “PUT /remote.php/webdav/FILE HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php5-fpm.sock”, host: “XXXX.XXXX.XXX” HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php5-fpm.sock:”, host: “XXXX.XXXX.XXX

From php5-fpm.log:

[10-Feb-2017 10:03:32] WARNING: [pool www] child 1097, script ‘/XXXXXX/remote.php’ (request: “PUT /remote.php”) execution timed out (304.222019 sec), terminating
[10-Feb-2017 10:03:32] WARNING: [pool www] child 1097 exited on signal 15 (SIGTERM) after 39000.551931 seconds from start

Can anyone help me diagnose this?

Thank you,


the question is: why is the php script timing out? Database unreachable? Anything else unreachable it needs when it comes to services? Or is the file you upload just really really big and the upload takes rather long? Then you have to increase the execution time of php-fpm and the timeout on the fcgi proxy settings for nginx. Else you get those. Also is the file “small enough” to fly under the upload limit radar?


The database, etc seem to be reachable. With each reboot, a few files do upload and I can navigate around on the web interface without any problems. At least until it hangs, then neither uploads or the web interface work. It times out on files that are only 300KB. It has also uploaded files the same size without problems.

Could there be a clue in the fact that the file doesn’t just fail, but hangs up the whole system?

Is there an easy way to tell which thing is timing out?



run htop and/or iotop and watch closely what happens. I guess cpu load and/or load on the storage backend should give you an idea of what’s going on.


I have the same slow problems, I think that we have the same setup. I have an RPI 3, with latest Raspbian, and nginx, mariaDB, php5 from oficial repositiories.

I’m using a HDD as rootfs, at first (last week) I had 37MB/s of writing speed. Today I have installed Nextcloud 11. I have checked the I/O tansfer speed of the HDD and now I’m experiencing like 4MB/s or less. Can you check if you have the same problem?

I’m using this command:
sync; time dd if=/dev/zero of=/home/pi/testfile bs=1G count=1 oflag=direct ; sync

PS: I have lost my connection to the PI. Looks like it is frozen.

My bad… do not run the command of the last post. It will use all your ram.

Use this command instead
sync; time dd if=/dev/zero of=/home/pi/testfile bs=100M count=10 oflag=direct ; sync
10+0 records in
10+0 records out
1048576000 bytes (1.0 GB) copied, 26.9744 s, 38.9 MB/s

real 0m27.025s
user 0m0.010s
sys 0m2.290s

now I think that is not my HDD.

Interesting-- I hadn’t thought about the HDD speed as the hang up. My results are a little slower than yours, but I’m not sure if it would be enough to cause a problem.

sync; time dd if=/dev/zero of=/path/to/HDD/testfile bs=100M count=10 oflag=direct ; sync
10+0 records in
10+0 records out
1048576000 bytes (1.0 GB) copied, 34.1783 s, 30.7 MB/s

real 0m34.303s
user 0m0.010s
sys 0m2.140s

Hey folks,

I’m experiencing a similar issue using DietPi with Lighttpd and MySQL. I have a lot of FLAC files to upload and the sync will start, go up to about 74MB, freeze and then a couple minutes later cancel.

My RAM isn’t being eaten up and there’s minimal CPU usage during the transfers, I can only assume that the process is timing out while the files are being sent through Ethernet to the external USB.

Unfortunately, I have no idea how to change it so this doesn’t happen :frowning:

As it turns out, it seems this issue was caused by the “Protection Shield” module of Bitdefender’s Free Antivirus so I’ll report it to them soon. Hope this helps somebody and you people find the answer you’re looking for soon!

Me to. And af CallumH003 it start working again, for a time.
I did change the webserver from Apache to lighttpd, and from there had only half the errors. So it is likely a matter of resources.