Error when assembling chunks, status code 504


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!):

$CONFIG = array (
  'instanceid' => '********',
  'passwordsalt' => '********',
  'secret' => '********',
  'trusted_domains' =>
  array (
    0 => '********',
  'datadirectory' => '/var/data/nextcloud/',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => 'https://********/',
  'dbname' => '********',
  'dbhost' => '********',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '********',
  'dbpassword' => '********',
  'installed' => true,
  '' => 'production',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'default_language' => 'fr',
  'skeletondirectory' => '',
  'trusted_proxies' =>
  array (
    0 => '********',
  'forwarded_for_headers' =>
  array (
  '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: - - [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] AH01075: Error dispatching request to : (polling)



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:

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.


Maybe my apache configuration can help.

sudo apache2ctl -DDUMP_CONFIG | grep -vE "^[ ]*#[ ]*[0-9]+:$"
# In file: /etc/apache2/apache2.conf
PidFile /var/run/apache2/
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
# 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.php index.xhtml index.htm
# In file: /etc/apache2/mods-enabled/info.conf
<Location /server-info>
  SetHandler server-info
  Require local
# 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
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
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 ".+\.phps$">
  Require all denied
<FilesMatch "^\.ph(ar|p|ps|tml)$">
  Require all denied
# 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
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
  <FilesMatch "\.txt$">
    Require all denied
  <Files "robots.txt">
    Require all granted
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 ? - - [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"


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.

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

1 Like

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!):

$CONFIG = array (
  'instanceid' => 'id',
  'passwordsalt' => 'secret',
  'secret' => 'victoria',
  'trusted_domains' =>
  array (
    0 => '',
  'datadirectory' => '/opt/nextcloud/data',
  'overwrite.cli.url' => '',
  'dbtype' => 'mysql',
  'version' => '',
  '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',

Yep, I can confirm - I had to increase and set TimeOut 3600 in the global httpd.conf to resolve the same problem. I think this should be added the the Admin documentation and somehow properly explained, TimeOut setting is not even present in the default apache conf file in Fedora/CentOS.


sorry for popping up this issue again, but where do I raise the timeout on nginx?
and what is the setting for it?


For my nginx setup it was enough to set the timeout to 10 min (600 seconds).

PHP FPM config

Add this line:

request_terminate_timeout = 600

Location of the config on my system: /usr/local/etc/php-fpm.d/nextcloud.conf

nginx config

Around/below the line fastcgi_pass php-handler; add this line:

fastcgi_read_timeout 600;

Location of my nginx conf: /usr/local/etc/nginx/conf.d/nextcloud.conf

I’m curious to figure out why this is taking so long tho, so made a thread about it:

1 Like

just updated to 20.0.02, still getting the [Error when assembling chunks, status code 504] error

Had the same issue. When uploading is finished i timed 30 seconds until i got the 504 error. Tried all apache en php settings mentioned, none worked.

Responsible was a HAProxy backend setting:
default is 30seconds:

timeout connect  30000
timeout server  30000

I hope you are not bored with this topic. I would like to ask for assistance concerning same issue. I have OMV5 on my raspberry pi and installed nginx and nextcloud via docker. At the end of uploading big file (8GB in my case) to NextCloud I am seeing “Error when assembling chunks, status code 504”. What are the full paths to config files you are advising to change on raspberry pi? Is “nano” ok for editing operation?

I found /etc/php/7.3/fpm/php.ini
I found /etc/nginx/nginx.conf
I didn’t find /etc/apache2/apache2.conf - i see only “conf-available” and “mods-available”
Where is global httpd.conf? Or should it be apache2.conf

I hope you tell me what worked with you guys. Thanks.

Where can I find them?

Has anybody ever managed to fix this when using nextcloud in a docker configuration behind NPM? Because I cannot for the life of me find the proper config files, I can find a .htaccess file in the nextcloud docker volume folder, but there’s no apache, nginx, or php.ini config files to be found at any default locations on the system, nor in the mounted container itself, very odd

Is that the *.conf file in /data/compose/*/data/nginx/proxy_host/ ?

there has to be a vhost conf file inside your npm container. can’t tell you right now the exact path, maybe inside a folder named “sites-enabled”…?
right now i’m only running apache proxy, I will take a look at NPM this weekend.

inside the nextcloud container, you have to change php-local.ini:
max_execution_time = 3600
post_max_size = 21G
upload_max_filesize = 20G

and also nginx.conf:
httpd {
fastcgi_connect_timeout 60;
fastcgi_send_timeout 1800;
fastcgi_read_timeout 1800;

I’m using the image: linuxserver/nextcloud
restart both containers

Hm, I cannot seem to find that in my npm container, no idea why, however I have some numbered .conf files for each container in the nginx proxy_host folder, could these be the correct ones? An example would be looking like this (changed some identifiable info):



server {
set $forward_scheme http;
set $server “”;
set $port 553;

listen 80;
listen [::]:80;

listen 443 ssl http2;
listen [::]:443 ssl http2;


Let’s Encrypt SSL

include conf.d/include/letsencrypt-acme-challenge.conf;
include conf.d/include/ssl-ciphers.conf;
ssl_certificate /etc/letsencrypt/live/npm-3/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/npm-3/privkey.pem;

Block Exploits

include conf.d/include/block-exploits.conf;

HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)

add_header Strict-Transport-Security “max-age=63072000; preload” always;

# Force SSL
include conf.d/include/force-ssl.conf;

access_log /data/logs/proxy-host-3_access.log proxy;
error_log /data/logs/proxy-host-3_error.log warn;

location / {

HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)

add_header Strict-Transport-Security “max-age=63072000; preload” always;

# Proxy!
include conf.d/include/proxy.conf;



include /data/nginx/custom/server_proxy[.]conf;