Uploading larger files like 7GB, ERROR: Could not open file

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 30.0.5
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 22.04.5
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • nginx 1.18
  • PHP version (e.g, 8.3):
    • 8.3.14
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • When i attempted to upload larger files
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Bare Metal
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • no

Summary of the issue you are facing:

If i attempt to upload a large file to my nextcloud, like a 7.9GB file. The upload will run as expected as seen below

But once done we will get an error in the network tab

Blockquotehttps://cloud.x.dk/remote.php/dav/uploads/ncadmin/web-file-upload-651d55fa05b3f7dc/.file
Request Method:
MOVE
Status Code:
504 Gateway Timeout

Log entries

Nextcloud

[no app in context] Error: Could not open file
	MOVE /remote.php/dav/uploads/ncadmin/web-file-upload-661b74325d2924f6/.file
	from 10.100.0.2 by ncadmin at 21 Jan 2025, 13:11:00

Web server / Reverse Proxy

The output of your Apache/nginx/system log in /var/log/____:

Nothing in nextcloud.error
And i cant seem to find anything usefull in nextcloud.access

Configuration

Nextcloud

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.x.dk",
            "10.100.0.122",
            "localhost"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "https:\/\/cloud.x.dk\/",
        "overwritehost": "cloud.x.dk",
        "overwriteprotocol": "https",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "30.0.5.1",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "DK",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "maintenance_window_start": 2,
        "simpleSignUpLink.shown": false,
        "maintenance": false,
        "theme": "",
        "loglevel": 2,
        "tempdirectory": "\/nextcloud_tmp"
    }
}

Apps

  - activity: 3.0.0
  - app_api: 4.0.5
  - bruteforcesettings: 3.0.0
  - calendar: 5.0.9
  - circles: 30.0.0
  - cloud_federation_api: 1.13.0
  - collectives: 2.15.2
  - comments: 1.20.1
  - contacts: 6.1.3
  - contactsinteraction: 1.11.0
  - dav: 1.31.1
  - deck: 1.14.3
  - external: 5.5.2
  - federatedfilesharing: 1.20.0
  - federation: 1.20.0
  - files: 2.2.0
  - files_downloadlimit: 3.0.0
  - files_pdfviewer: 3.0.0
  - files_reminders: 1.3.0
  - files_sharing: 1.22.0
  - files_trashbin: 1.20.1
  - files_versions: 1.23.0
  - firstrunwizard: 3.0.0
  - impersonate: 1.17.1
  - integration_openai: 3.3.0
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - nextcloud_announcements: 2.0.0
  - notes: 4.11.0
  - notifications: 3.0.0
  - oauth2: 1.18.1
  - password_policy: 2.0.0
  - photos: 3.0.2
  - privacy: 2.0.0
  - provisioning_api: 1.20.0
  - recommendations: 3.0.0
  - related_resources: 1.5.0
  - richdocuments: 8.5.3
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - sharebymail: 1.20.0
  - spreed: 20.1.3
  - support: 2.0.0
  - survey_client: 2.0.0
  - systemtags: 1.20.0
  - tables: 0.8.3
  - text: 4.1.0
  - theming: 2.5.0
  - theming_customcss: 1.18.0
  - twofactor_backupcodes: 1.19.0
  - twofactor_webauthn: 2.0.0
  - updatenotification: 1.20.0
  - user_status: 1.10.0
  - viewer: 3.0.0
  - weather_status: 1.10.0
  - webhook_listeners: 1.1.0-dev
  - workflowengine: 2.12.0
Disabled:
  - admin_audit: 1.20.0
  - dashboard: 7.10.0 (installed 7.6.0)
  - encryption: 2.18.0
  - files_external: 1.22.0
  - files_linkeditor: 1.1.21 (installed 1.1.21)
  - files_rightclick: 0.15.1 (installed 1.6.0)
  - groupfolders: 18.0.8 (installed 18.0.8)
  - suspicious_login: 8.0.0
  - twofactor_nextcloud_notification: 4.0.0
  - twofactor_totp: 12.0.0-dev
  - user_ldap: 1.21.0

NGINX config

nginx/conf.d/nextcloud.conf

server {
    listen 80;
    listen [::]:80;
    server_name cloud.x.dk;
 
    # Add headers to serve security related headers
    add_header Referrer-Policy                   "no-referrer"       always;
    add_header X-Content-Type-Options            "nosniff"           always;
    add_header X-Download-Options                "noopen"            always;
    add_header X-Frame-Options                   "SAMEORIGIN"        always;
    add_header X-Permitted-Cross-Domain-Policies "none"              always;
    add_header X-Robots-Tag                      "noindex, nofollow" always;
    add_header X-XSS-Protection                  "1; mode=block"     always;
    add_header Strict-Transport-Security "max-age=15552000; includeSubDomains; preload";
 
    #I found this header is needed on Ubuntu, but not on Arch Linux.
 
    # Path to the root of your installation
    root /var/www/nextcloud/;
 
    access_log /var/log/nginx/nextcloud.access;
    error_log /var/log/nginx/nextcloud.error;
 
 
        # set max upload size
    client_max_body_size 100G;
    client_body_buffer_size 2024m;
    client_body_temp_path /nextcloud_tmp;
    client_body_timeout 6400s;
    proxy_buffering off;
    fastcgi_max_temp_file_size 0;
    fastcgi_buffers 64 4K;
    add_header X-Accel-Buffering no;
    add_header X-XSS-Protection                  "1; mode=block"     always;
 
 
    # Disable gzip to avoid the removal of the ETag header
    gzip off;
 
    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed off;
 
    error_page 403 /core/templates/403.php;
    error_page 404 /core/templates/404.php;
 
    index index.php index.html /index.php$request_uri;
 
    # Rule borrowed from `.htaccess` to handle Microsoft DAV clients
    location = / {
        if ( $http_user_agent ~ ^DavClnt ) {
            return 302 /remote.php/webdav/$is_args$args;
        }
    }
 
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
 
    # Make a regex exception for `/.well-known` so that clients can still
    # access it despite the existence of the regex rule
    # `location ~ /(\.|autotest|...)` which would otherwise handle requests
    # for `/.well-known`.
    location ^~ /.well-known {
        # The rules in this block are an adaptation of the rules
        # in `.htaccess` that concern `/.well-known`.
 
        location = /.well-known/carddav { return 301 /remote.php/dav/; }
        location = /.well-known/caldav  { return 301 /remote.php/dav/; }
 
        location /.well-known/acme-challenge    { try_files $uri $uri/ =404; }
        location /.well-known/pki-validation    { try_files $uri $uri/ =404; }
 
        # Let Nextcloud's API for `/.well-known` URIs handle all other
        # requests by passing them to the front-end controller.
        return 301 /index.php$request_uri;
    }
 
    # Rules borrowed from `.htaccess` to hide certain paths from clients
    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/)  { return 404; }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console)                { return 404; }
 
    # Ensure this block, which passes PHP files to the PHP process, is above the blocks
    # which handle static assets (as seen below). If this block is not declared first,
    # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
    # to the URI, resulting in a HTTP 500 error response.
    location ~ \.php(?:$|/) {
        # Required for legacy support
        rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri;
 
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        set $path_info $fastcgi_path_info;
 
        try_files $fastcgi_script_name =404;
 
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param HTTPS on;
 
        fastcgi_param modHeadersAvailable true;         # Avoid sending the security headers twice
        fastcgi_param front_controller_active true;     # Enable pretty urls
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_connect_timeout 120;
        fastcgi_send_timeout 4800;
        fastcgi_read_timeout 4800;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }
    location ~ \.(?:css|js|svg|gif|png|jpg|ico|wasm|tflite)$ {
        try_files $uri /index.php$request_uri;
        expires 6M;         # Cache-Control policy borrowed from `.htaccess`
        access_log off;     # Optional: Don't log access to assets
 
        location ~ \.wasm$ {
            default_type application/wasm;
        }
    }
 
 
    # Set .mjs and .wasm MIME types
    # Either include it in the default mime.types list
    # and include that list explicitly or add the file extension
    # only for Nextcloud like below:
    include mime.types;
    types {
        text/javascript js mjs;
        application/wasm wasm;
    }
 
    location ~ \.woff2?$ {
        try_files $uri /index.php$request_uri;
        expires 7d;         # Cache-Control policy borrowed from `.htaccess`
        access_log off;     # Optional: Don't log access to assets
    }
 
    # Rule borrowed from `.htaccess`
    location /remote {
        return 301 /remote.php$request_uri;
    }
 
    location / {
        try_files $uri $uri/ /index.php$request_uri;
    }
}

PHP config

php/8.3/fpm/php.ini
https://pastebin.com/Sg2Y8KY8

##nextcloud panel

How long does the upload run? Does that match one of the *timeout values in the configuration files you shared?

1 Like

This is the likely relevant value (e.g. see here).

And AFAIK it needs an s appended to it as described in the Nginx docs: Module ngx_http_fastcgi_module

Some of your other values may be impacted by that as well.

I did a upload test and it took 7 minutes, which is like 420 seconds

Looking over the timeout settings that i can find, the only i have below 420 is:
fastcgi_connect_timeout 120; which i dont think it is
and in php i had:
default_socket_timeout = 60 which ive now turned to 2400, i really thought this was the issue, but sadly we have the same error.

Any more ideas?

From what i can find online nginx should use seconds if a unit of measurement is not provided, i changed it all to seconds tho so we now have:

    client_max_body_size 100G;
    client_body_buffer_size 2024m;
    client_body_temp_path /nextcloud_tmp;
    client_body_timeout 6400s;
    proxy_buffering off;
    fastcgi_max_temp_file_size 0;
    fastcgi_buffers 64 4K;
    add_header X-Accel-Buffering no;
    add_header X-XSS-Protection                  "1; mode=block"     always;
    fastcgi_connect_timeout 4800s;
    fastcgi_send_timeout 4800s;
    fastcgi_read_timeout 4800s;

But sadly same error.

I have the same issue with version 30.0.5-fpm.

In the older version 30.0.2-fpm, this problem did not occur.

1 Like

@jtr and @wbk
Ive recorded a small video if that helps.