Error when assembling chunks, status code 504

Hello,

I have a strange error a the end of a file upload. :confused:

Nextcloud version : 16.0.3
Operating system and version : Ubuntu 18.04 LTS
Apache or nginx version : Apache 2.4.29
PHP version : 7.3

The issue you are facing:

Error when assembling chunks, status code 504

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

Steps to replicate it:

  1. Upload a large file (1.9GB in my example)
  2. Wait for the and of the transfer, the error message is displayed

After less than a minute, If I refresh the page, the file is well accessible.

The output of your Nextcloud log in Admin > Logging:

Nothing here :/ 

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

<?php
$CONFIG = array (
  'instanceid' => '********',
  'passwordsalt' => '********',
  'secret' => '********',
  'trusted_domains' =>
  array (
    0 => '********',
  ),
  'datadirectory' => '/var/data/nextcloud/',
  'dbtype' => 'mysql',
  'version' => '16.0.3.0',
  'overwrite.cli.url' => 'https://********/',
  'dbname' => '********',
  'dbhost' => '********',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '********',
  'dbpassword' => '********',
  'installed' => true,
  'updater.release.channel' => 'production',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'default_language' => 'fr',
  'skeletondirectory' => '',
  'trusted_proxies' =>
  array (
    0 => '********',
  ),
  'forwarded_for_headers' =>
  array (
    0 => 'HTTP_X_FORWARDED_FOR',
  ),
  'versions_retention_obligation' => 'disabled',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '********',
    'port' => 6379,
    'password' => '********',
  ),
  'htaccess.RewriteBase' => '/',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '********-noreply',
  'mail_domain' => '********',
  'mail_smtphost' => '********',
  'mail_smtpport' => '25',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 1,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'tempdirectory' => '/tmp', // Doesn't seemd used anyway o_O
);

The output of your Apache log in /var/log/apache2/nextcloud_access.log:

77.158.xxx.xxx - - [16/Jul/2019:16:13:56 +0200] "MOVE /remote.php/dav/uploads/********/web-file-upload-d042998e989dcf265656cbcb4a8d0c40-1563286115438/.file HTTP/1.0" 504 676 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"

The output of your Apache log in /var/log/apache2/nextcloud_error.log (don’t know if it is relevant):

[Tue Jul 16 16:14:06.509389 2019] [proxy_fcgi:error] [pid 9529:tid 140092236625664] (70007)The timeout specified has expired: [client 10.0.100.10:51346] AH01075: Error dispatching request to : (polling)

Regards.

hello,

the only clue is see is themax_execution_time = value in your php.ini (/etc/php/7.3/cgi/php.ini or php.local.ini )

You migth want to check the value. i use 300.

AND/OR check your php.ini memory value ( check them all )

old 2018 message for same er’ror in owncloud: https://central.owncloud.org/t/solved-error-when-assembling-chunks-uploading-large-files-to-s3-folder/16922

Here is an extract of /etc/php/7.3/fpm/php.ini.

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
max_execution_time = 3600
max_input_time = 3600
max_input_vars = 1000
memory_limit = 512M

;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;
post_max_size = 16G

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
file_uploads = On
upload_tmp_dir = /tmp/
upload_max_filesize = 16G
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off

I don’t see what could cause the issue.

Regards.

Maybe my apache configuration can help.

sudo apache2ctl -DDUMP_CONFIG | grep -vE "^[ ]*#[ ]*[0-9]+:$"
# In file: /etc/apache2/apache2.conf
PidFile /var/run/apache2/apache2.pid
Timeout 10
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User www-data
Group www-data
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel notice core:info
# In file: /etc/apache2/mods-enabled/alias.conf
Alias /icons/ "/usr/share/apache2/icons/"
<Directory "/usr/share/apache2/icons">
  Options FollowSymlinks
  AllowOverride None
  Require all granted
</Directory>
# In file: /etc/apache2/mods-enabled/deflate.conf
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/xml
# In file: /etc/apache2/mods-enabled/dir.conf
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
# In file: /etc/apache2/mods-enabled/info.conf
<Location /server-info>
  SetHandler server-info
  Require local
</Location>
# In file: /etc/apache2/mods-enabled/mime.conf
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-bzip2 .bz2
AddLanguage am .amh

[... Many AddLanguage ...]

AddLanguage zh-TW .zh-tw
AddCharset us-ascii     .ascii .us-ascii

[... Many AddCharset ...]

AddCharset BRF           .brf
AddHandler type-map var
AddType text/html .shtml
# In file: /etc/apache2/mods-enabled/mpm_event.conf
StartServers 3
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 250
MaxConnectionsPerChild 0
# In file: /etc/apache2/mods-enabled/setenvif.conf
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "MS FrontPage" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
BrowserMatch "^gnome-vfs/1.0" redirect-carefully
BrowserMatch "^gvfs/1" redirect-carefully
BrowserMatch "^XML Spy" redirect-carefully
BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
BrowserMatch " Konqueror/4" redirect-carefully
# In file: /etc/apache2/mods-enabled/ssl.conf
SSLRandomSeed startup builtin
SSLRandomSeed startup file:/dev/urandom 512
SSLRandomSeed connect builtin
SSLRandomSeed connect file:/dev/urandom 512
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLPassPhraseDialog exec:/usr/share/apache2/ask-for-passphrase
SSLSessionCache shmcb:/var/run/apache2/ssl_scache(512000)
SSLSessionCacheTimeout 300
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
SSLHonorCipherOrder On
SSLProtocol all -SSLv3 -TLSv1
SSLInsecureRenegotiation Off
SSLCompression Off
# In file: /etc/apache2/ports.conf
Listen 80
Listen 443
# In file: /etc/apache2/apache2.conf
AccessFileName .htaccess
<FilesMatch "^\.ht">
  Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# In file: /etc/apache2/conf-enabled/other-vhosts-access-log.conf
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
# In file: /etc/apache2/conf-enabled/php7.3-fpm.conf
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
<FilesMatch ".+\.ph(ar|p|tml)$">
  SetHandler "proxy:unix:/run/php/php7.3-fpm.sock|fcgi://localhost"
</FilesMatch>
<FilesMatch ".+\.phps$">
  Require all denied
</FilesMatch>
<FilesMatch "^\.ph(ar|p|ps|tml)$">
  Require all denied
</FilesMatch>
# In file: /etc/apache2/conf-enabled/security.conf
AcceptFilter http data
AcceptFilter https data
Header always set X-XSS-Protection 1;mode=block
Header set X-Robots-Tag: none
ServerTokens Prod
ServerSignature Off
TraceEnable Off
Header set X-Content-Type-Options: "nosniff"
Header always set X-Frame-Options: "SAMEORIGIN"
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
RewriteEngine On
RewriteCond %{THE_REQUEST} !HTTP/1\.1$
RewriteRule .* - [F]
<FilesMatch "^\.ht">
  Require all denied
</FilesMatch>
Header set Cache-Control no-cache
Header set Pragma no-cache
# In file: /etc/apache2/sites-enabled/nextcloud.conf
<VirtualHost *:443>
  SSLEngine on
  SSLCertificateFile "/etc/security/pki/apache2/certs/********.cer"
  SSLCertificateKeyFile "/etc/security/pki/apache2/keys/********.pem"
  SSLCertificateChainFile "/etc/security/pki/ca/********.cer"
  DocumentRoot /opt/nextcloud/
  ServerName ********.com
  DirectoryIndex index.php
  LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined_corp
  ErrorLog /var/log/apache2/nextcloud_error.log
  CustomLog /var/log/apache2/nextcloud_access.log combined_corp
  <Directory /opt/nextcloud>
    Options +FollowSymLinks -Indexes -Includes -ExecCGI
    AllowOverride All
  </Directory>
  <FilesMatch "\.txt$">
    Require all denied
  </FilesMatch>
  <Files "robots.txt">
    Require all granted
  </Files>
</VirtualHost>
httpd (pid 22599) already running

Also, in the log bellow (/var/log/apache2/nextcloud_access.log), it seems that Nextcloud tries to move an hidden file (.file), and hidden files are not served by Apache maybe ?

77.158.xxx.xxx - - [16/Jul/2019:16:13:56 +0200] "MOVE /remote.php/dav/uploads/********/web-file-upload-d042998e989dcf265656cbcb4a8d0c40-1563286115438/.file HTTP/1.0" 504 676 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"

Hello

Since you are using php fpm you should check the value of request_terminate_timeout in the pool configuration (default: pool.d/www.conf)
Don’t forget to restart php-fpm service

Hello CICfe, the value is default (0), so if I understand well, it should not cause a timeout as it is disabled.
Regards.

Hello,
The main Apache Timeout was set to 10… :sweat:
I raised it to 3600 and the error message disappeared.
Regards.

Hi there,

same message, same behavior but I could not fix this issue with raising timeout.

First I set in php.ini

max_execution_time = 21600

Then in /etc/apache2/apache2.conf I set

Timeout 21600

Last thing I tried was adding

fastcgi_read_timeout 1d;
proxy_read_timeout 1d;

in the http section of /etc/nginx/nginx.conf

Nothing worked.
Can somebody tell me what I am missing?

Best regards

Nextcloud version: 16.0.3
Operating system and version : Ubuntu 16.04
Apache or nginx version: Apache/2.4.18 and nginx/1.14.2
PHP version: 7.3.7

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

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

<?php
$CONFIG = array (
  'instanceid' => 'id',
  'passwordsalt' => 'secret',
  'secret' => 'victoria',
  'trusted_domains' =>
  array (
    0 => 'nextcloud.my.domain',
  ),
  'datadirectory' => '/opt/nextcloud/data',
  'overwrite.cli.url' => 'https://nextcloud.my.domain',
  'dbtype' => 'mysql',
  'version' => '16.0.3.0',
  'dbname' => 'db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'admin',
  'dbpassword' => 'admin',
  'installed' => true,
  'maintenance' => false,
  'mail_smtpmode' => 'sendmail',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'my',
  'mail_domain' => 'adress',
  'mail_smtpsecure' => 'tls',
  'mail_smtphost' => 'smtp',
  'mail_smtpport' => '587',
  'theme' => '',
  'loglevel' => 2,
  'mail_smtpauth' => 1,
  'app_install_overwrite' =>
  array (
    0 => 'calendar',
  ),
  'filelocking.ttl' => 21600,
  'updater.secret' => 'secret',
);