Error BAD Request while uploading from client

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 28.0.3
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.58
PHP version (eg, 7.4): 8.2

The issue you are facing:

While uploding files from my phone i get 502 error code message.

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

The output of your Nextcloud log in Admin > Logging:

[no app in context] Error: Expected filesize of 4282528 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 974848 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/dav/files/9ECDF636-11C4-4B47-B758-4BD5C96C8E29/Photos/2024/03/24-03-17%2019-17-55%200578.mov
	from 162.158.129.244 by 9ECDF636-11C4-4B47-B758-4BD5C96C8E29 at 28 mar 2024, 20:19:24

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

<?php
$CONFIG = array (
  'passwordsalt' => '{secret}',
  'secret' => '{secret}',
  'trusted_domains' =>
  array (
    0 => 'xx.xx.xx.xx',
    1 => 'nextcloud.example.com',
    2 => 'nextcloud.example.com',
  ),
  'default_phone_region' => 'IT',
  'datadirectory' => '/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '28.0.3.2',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => '{hostname}:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '{secret}',
  'installed' => true,
  'instanceid' => 'oc7jo7m6fcxo',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'admin',
  'mail_domain' => 'example.com',
  'mail_smtphost' => 'smtps.example.com',
  'mail_smtpport' => '465',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '{mail@example.com}',
  'mail_smtppassword' => '{secret}',
  'loglevel' => 2,
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'xx.xx.xx.xx',
    'port' => 6379,
  ),
  'trusted_proxies' =>
  array (
    0 => 'xx.xx.xx.xx',
    1 => 'xx.xx.xx.xx',
  ),
  'allow_local_remote_servers' => true,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'maintenance' => false,
  'maintenance_window_start' => 1,
  'theme' => '',
);

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

172.16.1.5 - username [28/Mar/2024:19:46:04 +0000] "PUT /remote.php/dav/files/9ECDF636-11C4-4B47-B758-4BD5C96C8E29/Photos/2024/03/24-03-28%2008-20-07%20F3C0.jpg HTTP/1.1" 400 2721
172.16.1.5 - username [28/Mar/2024:19:46:06 +0000] "PUT /remote.php/dav/files/9ECDF636-11C4-4B47-B758-4BD5C96C8E29/Photos/2024/03/24-03-22%2016-54-36%200582.mov HTTP/1.1" 400 2721
172.16.1.5 - username [28/Mar/2024:19:46:08 +0000] "PUT /remote.php/dav/files/9ECDF636-11C4-4B47-B758-4BD5C96C8E29/Photos/2024/03/24-03-24%2011-27-10%200588.mov HTTP/1.1" 400 2721

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.

{
    "reqId": "VHVgOmC0nnkEZE2LRHCa",
    "level": 3,
    "time": "2024-03-28T19:46:22+00:00",
    "remoteAddr": "172.71.114.162",
    "user": "9ECDF636-11C4-4B47-B758-4BD5C96C8E29",
    "app": "no app in context",
    "method": "PUT",
    "url": "/remote.php/dav/files/9ECDF636-11C4-4B47-B758-4BD5C96C8E29/Photos/2024/03/24-03-22%2014-53-00%200581.mov",
    "message": "Expected filesize of 4104521 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1007616 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.",
    "userAgent": "Mozilla/5.0 (iOS) Nextcloud-iOS/5.2.3",
    "version": "28.0.3.2",
    "exception": {
        "Exception": "Sabre\\DAV\\Exception\\BadRequest",
        "Message": "Expected filesize of 4104521 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1007616 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.",
        "Code": 0,
        "Trace": [
            {
                "file": "/var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php",
                "line": 148,
                "function": "put",
                "class": "OCA\\DAV\\Connector\\Sabre\\File",
                "type": "->"
            },
            {
                "file": "/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
                "line": 1098,
                "function": "createFile",
                "class": "OCA\\DAV\\Connector\\Sabre\\Directory",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
                "line": 504,
                "function": "createFile",
                "class": "Sabre\\DAV\\Server",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/var/www/html/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
                "line": 89,
                "function": "httpPut",
                "class": "Sabre\\DAV\\CorePlugin",
                "type": "->"
            },
            {
                "file": "/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
                "line": 472,
                "function": "emit",
                "class": "Sabre\\DAV\\Server",
                "type": "->"
            },
            {
                "file": "/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
                "line": 253,
                "function": "invokeMethod",
                "class": "Sabre\\DAV\\Server",
                "type": "->"
            },
            {
                "file": "/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
                "line": 321,
                "function": "start",
                "class": "Sabre\\DAV\\Server",
                "type": "->"
            },
            {
                "file": "/var/www/html/nextcloud/apps/dav/lib/Server.php",
                "line": 373,
                "function": "exec",
                "class": "Sabre\\DAV\\Server",
                "type": "->"
            },
            {
                "file": "/var/www/html/nextcloud/apps/dav/appinfo/v2/remote.php",
                "line": 35,
                "function": "exec",
                "class": "OCA\\DAV\\Server",
                "type": "->"
            },
            {
                "file": "/var/www/html/nextcloud/remote.php",
                "line": 172,
                "args": [
                    "/var/www/html/nextcloud/apps/dav/appinfo/v2/remote.php"
                ],
                "function": "require_once"
            }
        ],
        "File": "/var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/File.php",
        "Line": 301,
        "message": "Expected filesize of 4104521 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1007616 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.",
        "exception": [],
        "CustomMessage": "Expected filesize of 4104521 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1007616 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side."
    },
    "id": "6605c917401e0"
}

You are using a proxy? Just for large files?

For webserver and proxy, there are some limits you have to adjust to each other:
https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/big_file_upload_configuration.html

If you can log on the components individually, you can perhaps get the process that limits the transfer.

Hi i’m using a zevent load balancer in front of nextcloud for all services.