Large file uploads fail after 30 seconds

Nextcloud version: 23.0.4
Operating system and version: Ubuntu 20.04
Apache or nginx version: Apache 2.4.54
PHP version: 8.0
PHP Memory Limit: 512 MB
PHP Max Execution Time: 3600
PHP Upload max size: 2 MB

The issue I am facing:

When I try to upload a large file to my Nextcloud, the upload fails after 30 seconds. Depending on the speed of my connection, different amounts of data get transferred until it fails. I’ve tried uploading different files from different computers, but everything still fails after 30 seconds. Small files that can be uploaded within the 30 seconds get uploaded without issue. The weird part is that the error below gets generated right when the upload starts, not after 30 seconds. I am currently using a USB hard drive temporarily while I change the internal hard drive. Not sure if it’s related, but I hadn’t run into this issue before I switched to the USB hard drive.

Is this the first time you’ve seen this error?: Yes

Steps to replicate it:

  1. Upload a large file to Nextcloud

The output of Nextcloud log in Admin > Logging:

[no app in context] Error: Expected filesize of 2686451712 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 0 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.

PUT /remote.php/webdav/big.bin
from [IP Address] by admin at 2022-07-11T22:10:30+00:00

The output of config.php file in /path/to/nextcloud:

<?php
$CONFIG = array (
  'instanceid' => 'id',
  'passwordsalt' => 'salt',
  'secret' => 'secret',
  'trusted_domains' =>
  array (
    0 => 'nextcloud.domain.com',
    1 => '192.168.1.101',
  ),
  'datadirectory' => '/data/nextcloud',
  'default_phone_region' => 'CA',
  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\SVG',
  ),
  'dbtype' => 'mysql',
  'version' => '23.0.4.1',
  'overwrite.cli.url' => 'https://www.domain.com/nextcloud',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud_user',
  'dbpassword' => 'password',
  'installed' => true,
  'maintenance' => false,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/run/redis/redis-server.sock',
    'port' => 0,
  ),
  'theme' => '',
  'loglevel' => 2,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud.log',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'gmail.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '465',
  'mail_from_address' => 'email',
  'mail_smtpname' => 'email@gmail.com',
  'mail_smtppassword' => 'password',
  'updater.secret' => 'secret',
);

Increase this value. Because there are existing two php.ini, you should use the the one in /etc/php/apache

Maybe it will help you.

Hi Mornsgrans, thanks for the reply.

I tried changing upload_max_filesize in /etc/php/8.0/apache2/php.ini, /etc/php/8.0/fpm/php.ini, and /etc/php/8.0/cli/php.ini to 2G instead of 2M, but it didn’t fix the issue. Nextcoud also still shows 2MB as the max upload size. Where can I change this setting?

image

Sorry, the setting applied after restarting Apache, but uploads still fail.

Create a phpinfo.php in your webserver root (not Nextcloud):
<?php phpinfo(); ?>
and access it https://webserver/phpinfo.php (documentation). Find the values.

Read also this instructions.

Thanks devnull, that helped me discover the max_execution_time was set to 30 seconds. I changed it to 3600 seconds (1 hour), but unfortunately, the issue persists. I was also able to confirm that upload_max_filesize is set to 2G.

Do you use a reverse proxy? If yes check the configuration.
Also test to not set “2G” but “2048M” for 2 GB or “1024M” for 1 GB in your settings. Restart the apache2 or your server.

No, I don’t use a reverse proxy for Nextcloud, and 2048M instead of 2G didn’t work either…