Error when assembling chunks. Status code 504 on big file upload

My setup:
All services run on my raspberry pi, started with docker-compose (given with used images)
Nextcloud 20.0.2 - nextcloud:latest
nginx - alexanderkrause/rpi-nginx-proxy:latest
letsencrypt - alexanderkrause/rpi-letsencrypt-nginx-proxy-companion:latest
MariaDB - jsurf/rpi-mariadb:latest

The issue you are facing:
I want to upload a file with 4.4 GB (over web interface or windows client - does not matter) and the upload goes through. At the end I get the error “Error when assembling chunks. Status code 504”. When I upload the file with the windows client a file gets created in nextcloud, but it is a little bigger than 400MB and not the total 4.4 GB.

Is this the first time you’ve seen this error?
Yes, but I never uploaded such a big file before.

The output of your Nextcloud log in Admin > Logging:
I can not find a directly related log entry. Same story with “docker logs nextcloud”. In Admin > Logging I fond the following:

[webdav] Fatal: Sabre\DAV\Exception: Error while copying file to target location (copied bytes: -1, expected filesize: -1 ) at <<closure>>

 0. /var/www/html/apps/dav/lib/Connector/Sabre/Directory.php line 155
 1. /var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php line 311
    OCA\DAV\Connector\Sabre\Directory->createFile("complete_dataset.csv", null)
 2. /var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php line 135
    Sabre\DAV\Tree->copyNode(OCA\DAV\Upload\FutureFile {}, OCA\DAV\Connector\Sabre\Directory {}, "complete_dataset.csv")
 3. /var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php line 167
    Sabre\DAV\Tree->copy("uploads/Tobias/ ... e", "files/Tobias/FH ... v")
 4. /var/www/html/apps/dav/lib/Upload/ChunkingPlugin.php line 95
    Sabre\DAV\Tree->move("uploads/Tobias/ ... e", "files/Tobias/FH ... v")
 5. /var/www/html/apps/dav/lib/Upload/ChunkingPlugin.php line 77
    OCA\DAV\Upload\ChunkingPlugin->performMove("uploads/Tobias/ ... e", "files/Tobias/FH ... v")
 6. /var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    OCA\DAV\Upload\ChunkingPlugin->beforeMove("uploads/Tobias/ ... e", "files/Tobias/FH ... v")
 7. /var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 632
    Sabre\DAV\Server->emit("beforeMove", ["uploads/Tobias ... "])
 8. /var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpMove(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
 9. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 474
    Sabre\DAV\Server->emit("method:MOVE", [Sabre\HTTP\Requ ... }])
10. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 251
    Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
11. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 319
12. /var/www/html/apps/dav/lib/Server.php line 332
13. /var/www/html/apps/dav/appinfo/v2/remote.php line 35
14. /var/www/html/remote.php line 167
    require_once("/var/www/html/a ... p")

MOVE /remote.php/dav/uploads/Tobias/web-file-upload-34b6609342212e629dd8ed1f7973a0db-1606827345313/.file
from by Tobias at 2020-12-01T13:11:10+00:00

What I already tried:

  1. nginx container - /etc/nginx/nginx.conf
    added the following lines in http segment:
client_max_body_size 0;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 1800;
fastcgi_read_timeout 1800;
  1. nextcloud container - added file in /usr/local/etc/php/conf.d/tweak.ini with content:
post_max_size = 100G
upload_max_filesize = 100G

No success…

I really hope someone can help me here! :slight_smile:
Thanks in advance!


I have the same behaviour, same settings. Try everythings, but nothing achieved. Hope someone could help us!


I have a solution, but maybe not in a way you expected.

My nextcloud docker container is now on version 20.0.4. Recently I switched from nginx to traefik v2. Now the upload went through and everything works. My nextcloud container still has the settings mentioned above.

So if you want to keep your nginx I think you have to search for the problem there. Good luck!

If you could point me to a proper tutorial for switching to Traefik v2, because I’m a bit lost :frowning:

I don’t know any good tutorial, because I knew traefik from work. But here are a few hints:

I use the official traefik 2 docker image. Put traefik and nextcloud in the same docker network. Now use traefik with these commands and these labels:

  - "--providers.docker=true"
  - "--providers.docker.exposedbydefault=false"
  - "--entrypoints.web.address=:80"
  - "--entrypoints.web.http.middlewares=redirect-to-https@docker" # use middleware defined in labels. Always redirect http to https
  - "--entrypoints.websecure.address=:443"
  - "--serverstransport.insecureskipverify=true"
  - ""
  - ""
  - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
 #  - "--certificatesresolvers.letsencrypt.acme.caserver=" use this for testing. Letsencrypt as a ratio limit on its production endpoint
 # - "--log.level=DEBUG"
 # - "--accesslog=true" help with finding errors
  - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
  - "traefik.http.middlewares.redirect-to-https.redirectscheme.permanent=true"

and now you add these labels to your nextcloud container:

  - "traefik.http.middlewares.nextcloud_headers.headers.stsSeconds=315360000" # for security mentioned in server overview
  - "traefik.http.middlewares.calcarddav.redirectregex.permanent=true"
  - "traefik.http.middlewares.calcarddav.redirectregex.regex=https://(.*)/.well-known/(card|cal)dav"
  - "traefik.http.middlewares.calcarddav.redirectregex.replacement=https://$$1/remote.php/dav/" # important für caldav and carddav
  - "traefik.enable=true"
  - "traefik.http.routers.nextcloud_http.rule=Host(``)"
  - "traefik.http.routers.nextcloud_http.entrypoints=web"
  - "traefik.http.routers.nextcloud_https.rule=Host(``)"
  - "traefik.http.routers.nextcloud_https.entrypoints=websecure"
  - "traefik.http.routers.nextcloud_https.middlewares=calcarddav,nextcloud_headers"
  - "traefik.http.routers.nextcloud_https.tls=true"
  - "traefik.http.routers.nextcloud_https.tls.certresolver=letsencrypt" # defined in traefik command

The traefik documentation is pretty good. Just remeber that everything defined in traefiks command area is its static configuration and all labels are a dynamic configuration. This fact caused me confusion many times :smiley:

Good luck!

1 Like

I’m just putting this here for people in the future who may be having this issue. Although I’m not using a plain ngnix docker container as my reverse proxy, I am using the Nginx Proxy Manager container to do all of my reverse proxy needs. I’ve been working on this for days trying to figure it out and tried all of the same things everyone else has tried until I saw a post on an Unraid forum. Adding these lines to the proxy config for Nextcloud fixed my issue

   proxy_connect_timeout 1d;
   proxy_send_timeout 1d;
   proxy_read_timeout 1d;
   send_timeout 1d;

Basically all this does is increase the timeouts on the nginx side to 1 day instead of whatever the default may be. Obviously this is probably way more than it needs to be, but it fixed my problem.

edit: Also just for clarification, this was in addition to the lines listed in the original post.

1 Like

Just to second it, these lines fixed the issue for me as well.

Hey I have a similar situation as you, also behind NPM in a container, do you happen to know which proxy config file I’m supposed to look for? I’ve added those lines to the file in /data/compose/6/data/nginx/proxy_host/4.conf (which corresponded to the domain that is forwarded to the nextcloud container on the same network), but it doesn’t seem to work

I just created an account to say thank you, it worked for me (y)