webdav ServiceUnavailable Could not open file

Nextcloud version (eg, 29.0.5): 29.0.6
Operating system and version (eg, Ubuntu 24.04): Ubuntu 22.04 with docker
Apache or nginx version (eg, Apache 2.4.25): nginx
PHP version (eg, 8.3): 8.3

The issue you are facing:

when uploading files this error will popup usually with larger files 10+gb, but smaller ones seem to have a similar problem.

altough at a way smaller frequency and anything above 10gb pretty much always errors out like this

looking inside the uploads folder shows all the incoming chunks and my suspission is something goes wrong during assembly, since the entire file transfers into the temporary folder in chunks but the errors out after a given amount of time. and even stranger after some random amount of time there is a 20% chance the file shows up later anyway even after all the errors but in 80% off all others cases nothing happens.

Is this the first time you’ve seen this error? (Y/N):

No this has been since 29.0.5 i believe and i have searched far and wide for a solution.
i have been running my nextcloud like this since nc27 and never had any issues.

Steps to replicate it:

  1. open nextcloud webui
  2. upload 20+gb (sometimes smaller files fail too)
  3. go to logging panel and see the error

The output of your Nextcloud log in Admin > Logging:

{
  "reqId": "BhtzS0jsYWB2fCo5JgyF",
  "level": 3,
  "time": "2024-09-05T03:39:55+00:00",
  "remoteAddr": "192.168.1.1",
  "user": "blackstorm",
  "app": "webdav",
  "method": "MOVE",
  "url": "/remote.php/dav/uploads/blackstorm/web-file-upload-7d9ac787d99950e2/.file",
  "message": "Could not open file",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
  "version": "29.0.6.1",
  "exception": {
    "Exception": "Sabre\\DAV\\Exception\\ServiceUnavailable",
    "Message": "Could not open file",
    "Code": 0,
    "Trace": [
      {
        "file": "/config/www/nextcloud/apps/dav/lib/Upload/AssemblyStream.php",
        "line": 294,
        "function": "get",
        "class": "OCA\\DAV\\Connector\\Sabre\\File",
        "type": "->"
      },
      {
        "file": "/config/www/nextcloud/apps/dav/lib/Upload/AssemblyStream.php",
        "line": 164,
        "function": "getStream",
        "class": "OCA\\DAV\\Upload\\AssemblyStream",
        "type": "->"
      },
      {
        "function": "stream_read",
        "class": "OCA\\DAV\\Upload\\AssemblyStream",
        "type": "->"
      },
      {
        "file": "/app/www/public/3rdparty/icewind/streams/src/Wrapper.php",
        "line": 55,
        "function": "fread"
      },
      {
        "file": "/app/www/public/3rdparty/icewind/streams/src/CallbackWrapper.php",
        "line": 96,
        "function": "stream_read",
        "class": "Icewind\\Streams\\Wrapper",
        "type": "->"
      },
      {
        "function": "stream_read",
        "class": "Icewind\\Streams\\CallbackWrapper",
        "type": "->"
      },
      {
        "file": "/app/www/public/lib/private/Files/Storage/Local.php",
        "line": 339,
        "function": "file_put_contents"
      },
      {
        "file": "/app/www/public/lib/private/Files/Storage/Local.php",
        "line": 650,
        "function": "file_put_contents",
        "class": "OC\\Files\\Storage\\Local",
        "type": "->"
      },
      {
        "file": "/app/www/public/lib/private/Files/Storage/Wrapper/Wrapper.php",
        "line": 653,
        "function": "writeStream",
        "class": "OC\\Files\\Storage\\Local",
        "type": "->"
      },
      {
        "file": "/app/www/public/lib/private/Files/Storage/Wrapper/Wrapper.php",
        "line": 653,
        "function": "writeStream",
        "class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
        "type": "->"
      },
      {
        "file": "/config/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php",
        "line": 250,
        "function": "writeStream",
        "class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
        "type": "->"
      },
      {
        "file": "/config/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php",
        "line": 148,
        "function": "put",
        "class": "OCA\\DAV\\Connector\\Sabre\\File",
        "type": "->"
      },
      {
        "file": "/app/www/public/3rdparty/sabre/dav/lib/DAV/Tree.php",
        "line": 325,
        "function": "createFile",
        "class": "OCA\\DAV\\Connector\\Sabre\\Directory",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/app/www/public/3rdparty/sabre/dav/lib/DAV/Tree.php",
        "line": 151,
        "function": "copyNode",
        "class": "Sabre\\DAV\\Tree",
        "type": "->"
      },
      {
        "file": "/app/www/public/3rdparty/sabre/dav/lib/DAV/Tree.php",
        "line": 181,
        "function": "copy",
        "class": "Sabre\\DAV\\Tree",
        "type": "->"
      },
      {
        "file": "/config/www/nextcloud/apps/dav/lib/Upload/ChunkingPlugin.php",
        "line": 94,
        "function": "move",
        "class": "Sabre\\DAV\\Tree",
        "type": "->"
      },
      {
        "file": "/config/www/nextcloud/apps/dav/lib/Upload/ChunkingPlugin.php",
        "line": 76,
        "function": "performMove",
        "class": "OCA\\DAV\\Upload\\ChunkingPlugin",
        "type": "->"
      },
      {
        "file": "/app/www/public/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "beforeMove",
        "class": "OCA\\DAV\\Upload\\ChunkingPlugin",
        "type": "->"
      },
      {
        "file": "/app/www/public/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
        "line": 603,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/app/www/public/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "httpMove",
        "class": "Sabre\\DAV\\CorePlugin",
        "type": "->"
      },
      {
        "file": "/app/www/public/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 472,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/app/www/public/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 253,
        "function": "invokeMethod",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/app/www/public/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 321,
        "function": "start",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/config/www/nextcloud/apps/dav/lib/Server.php",
        "line": 385,
        "function": "exec",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/config/www/nextcloud/apps/dav/appinfo/v2/remote.php",
        "line": 35,
        "function": "exec",
        "class": "OCA\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/app/www/public/remote.php",
        "line": 172,
        "args": [
          "/config/www/nextcloud/apps/dav/appinfo/v2/remote.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/config/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php",
    "Line": 505,
    "message": "Could not open file",
    "exception": [],
    "CustomMessage": "Could not open file"
  },
  "id": "66d92f682bbe7"
}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'datadirectory' => '/data',
  'instanceid' => 'REDACTED',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' => 
  array (
    0 => 'REDACTED',
    1 => 'REDACTED',
    2 => 'REDACTED',
    3 => 'REDACTED',
  ),
  'trusted_proxies' => 
  array (
    0 => 'REDACTED',
    1 => 'REDACTED',
  ),
  'dbtype' => 'mysql',
  'version' => '29.0.6.1',
  'overwrite.cli.url' => 'REDACTED',
  'dbname' => 'REDACTED',
  'dbhost' => 'REDACTED',
  'dbport' => 'REDACTED',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'REDACTED',
  'dbpassword' => 'REDACTED',
  'installed' => true,
  'default_phone_region' => 'BE',
  'maintenance_window_start' => 1,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\APCu',
  'upgrade.disable-web' => true,
  'mail_from_address' => 'status.blackstorm.cc',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'gmail.com',
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '587',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'REDACTED',
  'mail_smtppassword' => 'REDACTED',
  'defaultapp' => '',
  'maintenance' => false,
  'enable_previews' => true,
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\PNG',
    1 => 'OC\\Preview\\JPEG',
    2 => 'OC\\Preview\\GIF',
    3 => 'OC\\Preview\\BMP',
    4 => 'OC\\Preview\\XBitmap',
    5 => 'OC\\Preview\\MP3',
    6 => 'OC\\Preview\\TXT',
    7 => 'OC\\Preview\\MarkDown',
    8 => 'OC\\Preview\\OpenDocument',
    9 => 'OC\\Preview\\Krita',
    10 => 'OC\\Preview\\HEIC',
  ),
  'loglevel' => 2,
);

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

!!! Note: this isnt always accurate it seems.

increasing the timeout does not fix the issue and increasing the timeout to an unreasonable lenght doesnt do anything either.

2024/09/05 04:33:04 [error] 419#419: *26 upstream timed out (110: Operation timed out) while sending request to upstream, client: 192.168.1.1, server: _, request: "PUT /remote.php/dav/uploads/blackstorm/web-file-upload-db2a67c3be075d31/5 HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"
2024/09/05 04:35:12 [error] 419#419: *26 upstream timed out (110: Operation timed out) while sending request to upstream, client: 192.168.1.1, server: _, request: "PUT /remote.php/dav/uploads/blackstorm/web-file-upload-db2a67c3be075d31/425 HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"
2024/09/05 04:43:32 [error] 423#423: *1861 upstream timed out (110: Operation timed out) while reading response header from upstream, client: 192.168.1.1, server: _, request: "MOVE /remote.php/dav/uploads/blackstorm/web-file-upload-d0eec9771b83bd2b/.file HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"
2024/09/05 05:05:55 [error] 428#428: *4854 upstream timed out (110: Operation timed out) while sending request to upstream, client: 192.168.1.1, server: _, request: "PUT /remote.php/dav/uploads/blackstorm/web-file-upload-a1c8707e03deccc2/1654 HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"
2024/09/05 05:07:15 [error] 428#428: *4854 upstream timed out (110: Operation timed out) while sending request to upstream, client: 192.168.1.1, server: _, request: "PUT /remote.php/dav/uploads/blackstorm/web-file-upload-a1c8707e03deccc2/1776 HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"
2024/09/05 05:32:01 [error] 417#417: *9338 upstream timed out (110: Operation timed out) while sending request to upstream, client: 192.168.1.1, server: _, request: "PUT /remote.php/dav/uploads/blackstorm/web-file-upload-7d9ac787d99950e2/4170 HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"
2024/09/05 05:33:03 [error] 417#417: *9338 upstream timed out (110: Operation timed out) while sending request to upstream, client: 192.168.1.1, server: _, request: "PUT /remote.php/dav/uploads/blackstorm/web-file-upload-7d9ac787d99950e2/4170 HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"
2024/09/05 05:34:54 [error] 417#417: *9338 upstream timed out (110: Operation timed out) while sending request to upstream, client: 192.168.1.1, server: _, request: "PUT /remote.php/dav/uploads/blackstorm/web-file-upload-7d9ac787d99950e2/4295 HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"
2024/09/05 05:35:58 [error] 417#417: *9338 upstream timed out (110: Operation timed out) while sending request to upstream, client: 192.168.1.1, server: _, request: "PUT /remote.php/dav/uploads/blackstorm/web-file-upload-7d9ac787d99950e2/4295 HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"
2024/09/05 05:37:04 [error] 417#417: *9338 upstream timed out (110: Operation timed out) while sending request to upstream, client: 192.168.1.1, server: _, request: "PUT /remote.php/dav/uploads/blackstorm/web-file-upload-7d9ac787d99950e2/4329 HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"
2024/09/05 05:38:07 [error] 417#417: *9338 upstream timed out (110: Operation timed out) while sending request to upstream, client: 192.168.1.1, server: _, request: "PUT /remote.php/dav/uploads/blackstorm/web-file-upload-7d9ac787d99950e2/4329 HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"
2024/09/05 05:39:48 [error] 417#417: *9886 upstream timed out (110: Operation timed out) while reading response header from upstream, client: 192.168.1.1, server: _, request: "MOVE /remote.php/dav/uploads/blackstorm/web-file-upload-7d9ac787d99950e2/.file HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "nextcloud.blackstorm.cc"