Can't upload files larger than 512 MB

I have Nextcloud 10 running on a Raspberry Pi 3 with Jessie Lite, nginx, mariadb, redis, php7.0. I have gotten everything to work pretty well. My main issue right now is with large files. Using the web interface, files over 512 MB fail with an error after less than 30 seconds. Anything smaller than this is successful. Using WebDAV, the results seem to be similar (but the progress bar annoyingly goes to 99% rapidly and then sits there until the file finishes transferring, which could be many minutes). There are no errors or warnings in the log file when these large files fail.

I have followed the advice from many online forums and especially the nextcloud documentation here:

My temp folder is on a 74 GB SSD dedicated for this purpose and I can watch the temporary files get placed there and gain in size during a file transfer. After changing all of the values as prescribed in the following locations, I still can’t pass the 512 MB mark:

Not sure if it is relevant, but the admin page still says max file upload size is 2GB (even though the box beside it shows the larger size from the files I edited).
Does anyone have any advice on what I can do or how to troubleshoot this?


What is the value of these php settings as shown through phpinfo()?

Are you running 32, or 64 bit PHP? The max file upload size being limited to 2GB on the admin page indicates a 32bit system.

Hi @grouchysysadmin. Haha, love the name. Here are those values from the edited php.ini file (I cannot get my webserver to deliver the phpinfo webpage, it always just tries to download the file–that’s a separate issue I had trouble with):

–from php.ini–

I should mention that according to some advice, I have also set the same max size values in the .htaccess file. It has its own memory limit set at 512M. The .user.ini also has some of these values. They currently match the ones in .htaccess (70G and 512M).

I thought the Raspberry Pi 3 was 64-bit. I downloaded php7.0 using apt-get stretch. If there is a 32 and 64 bit version, I was unaware.

Hi @koreywithak

Can you create a file called test.php in the same folder as your Nextcloud installation with the following values.


Open this file in your browser to see the phpinfo. The reason for checking this specifically is to see what values the web server thinks is set. It’s possible that your values are being overridden somehow.

Yes, every time I have tried this and go to (for this example) https://mydomain.tld/test.php, it simply downloads the text file I have created. It does not show a webpage with the php information we are seeking.

I’m confused. Does Nextcloud work? If Nextcloud works, then any other PHP file should work unless you have some type of odd web server rewrite. I would try and resolve that first.

Also, keep in mind the .htaccess wont be read if you’re using Nginx.

Yeah nextcloud works fine. After some detective work, I was able to get my newly-named my_phpinfo page to display. It was a problem with my configuration, which I followed mostly from nextcloud’s recommendation. I added my new file between two pipes:

(location ~ ^/nextcloud/(?:index|my_phpinfo|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34]).php(?:$|/) {)

Here are the values from the displayed phpinfo page (left side is local and right side is master)
upload_max_filesize 70G 500G
post_max_size 70G 500G
memory_limit 512M 128M
max_input_time 3600 3600
max_execution_time 3600 3600

Your memory_limit is 512MB. Your uploads are failing at 512MB. Coincidence?

I’m new to most of this and I thought the memory_limit was related to chunking or something and not the total file size of an upload. I did change that at one point, but changed it back.

How high of a value can I set the memory_limit to?
I was fiddling with 70G and 500G as the max sizes because my tmp folder is on a 74 GB SSD and I figured that would be the max (my final storage location is a 2 TB hard drive)

In fact, the nexcloud documentation points to a wiki for nginx that says “High memory_limit is not required because the file will be directly streamed to disk”


I don’t know for sure, as I’ve never tried to upload a file that big through the web interface.

Are you able to upload large files using the Nextcloud/ownCloud client?
Do you happen to have buffering turned on for Nginx?
In PHP, what is ‘output_buffering’ set to?

  1. I’m now trying the Nextcloud client again (I don’t remember the results of previous tests). However, I plan to do one-time uploads to my server (I don’t want to synchronize a folder). It at least seems to be making progress and hasn’t failed yet. I tried WebDAV and it acts funny (as described above). It ended up getting a file stuck in a locked state, which took me a long time to resolve.
  2. My nginx settings related to buffering have not been changed from defaults:
    fastcgi_request_buffering off
    client_body_buffer_size 16k
    fastcgi_buffers 64 4K
  3. output_buffering in PHP is 0 locally and 4096 in the master. I haven’t touched those settings in any of the configuration files.

This might be related: the estimated time to complete a file upload using the web interface (whether small or large and whether it fails or is successful) is always erratic. For a large file it can continuously bounce from 3 hours to 11 hours and never settle or average out to something reasonable.

I’m testing the web interface upload using similar settings. Nginx, with a 512MB memory limit. The file I’m uploading is 618MB. I’ll report back as soon as it finishes or I receive an error.

One more thing to check is the ‘client_max_body_size’ setting of Nginx. That needs to be larger than the body size of the the file you are trying to upload.

Yes, in nginx I have the following set:
client_max_body_size 500G;

My test succeed. I was able to upload a 618MB file through the web interface using the following settings.

PHP settings


Nginx FastCGI Timeouts

# Connection timeout
fastcgi_connect_timeout 2;

# Transfer timeout
fastcgi_send_timeout 2;

# Receive timeout. Set higher to allow lengthy PHP script execution
fastcgi_read_timeout 240;

# Large buffer sizes for complex websites.
fastcgi_buffers 32 32k;
fastcgi_buffer_size 32k;
fastcgi_max_temp_file_size 0;

Nginx Nextcloud specific settings.

# Nextcloud overrides 
client_max_body_size 1G;

# Literal locations #

# Default location
location / {
        rewrite ^/remote/(.*) /remote.php last;
        rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;

# Regex locations #

# Caldav and Carddav rewrites
location ~ /.well-known/(cal|card)dav {
        return 301 $scheme://$host/remote.php/dav;

# Deny access to the following folders
location ~ ^/(build|tests|config|lib|3rdparty|templates|data)/ {
        deny all;

# Deny access to the following files
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;

# PHP location block #
location ~ [^/]\.php(/|$) {
        try_files $fastcgi_script_name =404;
        include /path/to/fastcgi settings file;
        fastcgi_pass unix:/path/to/$server_name.socket;

# Cache css and javascript
location ~* \.(?:css|js)$ {
        add_header Cache-Control "public, max-age=7200";
        access_log off;

# Do not log media files
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ {
        access_log off;

Can you compare your settings to mine to see if anything stands out?
Edit: I do not have redis. Can you try disabling that to test with?

1 Like

Before modifying anything per your last post, the 700 MB upload via the Nextcloud client on my Windows computer did succeed (although a notification said it failed).

I scrutinized all of my files very closely and I found that client_max_body_size was later overwritten by another client_max_body_size of 512M. I thought this was the culprit but the upload just failed again. I’m going to restart the server and try it again. One good sign is that after restarting the client and server computers (although I had restarted php and nginx already) the upload seems to be going faster and the time estimate is much more accurate. Here’s for hoping…

Okay all of my settings are like yours except where you have __G for size I used 10G and anything related to time I have 10000. Now I get either a gateway timeout or “Upload error: 3 - The uploaded file was only partially uploaded” on the Nextcloud website for files over about 50 MB.

After the failures in the above paragraph, the gateway timeouts gave me some information to go off of. I found this website and made corresponding edits. I also read more about the memory_limit and I think 512M might be too much, so I set it to 128M. I commented out the fast_cgi_connect and fast_cgi_timeout lines. I set the max_input_time to -1 (ignored) because the max_execution_time is really the main limiter, from what I read. I also set request_terminate_timeout = 3600 in /etc/php/7.0/fpm/pool.d/www.conf. I just uploaded a 400 MB file. I think the request_terminate_timeout is probably the main fix. I’m tired and I’ll try a bigger file tomorrow.

Yeah the large files are still failing and the speeds seems to be worse the larger the file is. I can upload small files (less than 50 MB) at about 1.00 megabyte per second. These bigger files average about 0.05 megabytes per second.

Hi @koreywithak,

Can you share the complete configurations? Perhaps someone will notice something that may help.

The only other guess I have is that you’re using a resource constrained device and that may be causing issues somehow. But I don’t see how that would case the files to fail in less than 30 seconds.

Also, did you try testing with redis disabled?

The Raspberry Pi 3 might be speed constrained, but it is supposed to be 64-bit with 1GB of RAM. I also have a 74 GB SSD for temp and a 2 TB HDD for storage. I feel like something else is the issue, especially since it does well with smaller files. Bigger files should be the same, just with more chunks, as I understand.

I tried it after stopping redis and the results were the same. Here are some configuration files. I began each file with ***** so that they were easily identifiable. I also removed the commented lines to shorten some of them.


upstream php-handler {
    #server unix:/var/run/php5-fpm.sock;

server {
    listen 80;
    server_name mydomain.tld;
    # enforce https
    return 301 https://$server_name$request_uri;

server {
    listen 443 ssl;
    server_name mydomain.tld;

    ssl_certificate /etc/letsencrypt/live/mydomain.tld/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mydomain.tld/privkey.pem;

    #Added by me for extra security
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_stapling on;
    ssl_stapling_verify on;

    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
    add_header Strict-Transport-Security "max-age=15768000; includeSubDomains" always;
    # preload;";
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;

    # Path to the root of your installation
    root /var/www/;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;

    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.
    # rewrite ^/.well-known/host-meta /nextcloud/public.php?service=host-meta
    # last;
    #rewrite ^/.well-known/host-meta.json
    # /nextcloud/public.php?service=host-meta-json last;

    location = /.well-known/carddav {
      return 301 $scheme://$host/nextcloud/remote.php/dav;
    location = /.well-known/caldav {
      return 301 $scheme://$host/nextcloud/remote.php/dav;
    location ^~ /.well-known/acme-challenge/ {
        default_type "text/plain";
        allow all;
        root /var/www/tmp/certbot;
    # Hide /acme-challenge subdirectory and return 404 on all requests.
    # It is somewhat more secure than letting Nginx return 403.
    # Ending slash is important!
    location = /.well-known/acme-challenge/ {
        return 404;

    location ^~ /nextcloud {
        # set max upload size
        client_body_temp_path /media/cloud_temp/temp;
        client_max_body_size 2G;
        client_body_buffer_size 16k;
        client_body_timeout 60s;
        fastcgi_buffers 64 4K;

        # Disable gzip to avoid the removal of the ETag header
        gzip off;

        # Uncomment if your server is build with the ngx_pagespeed module
        # This module is currently not supported.
        #pagespeed off;

        error_page 403 /nextcloud/core/templates/403.php;
        error_page 404 /nextcloud/core/templates/404.php;

        location /nextcloud {
            rewrite ^ /nextcloud/index.php$uri;

        location ~ ^/nextcloud/(?:build|tests|config|lib|3rdparty|templates|data)/ {
            deny all;
        location ~ ^/nextcloud/(?:\.|autotest|occ|issue|indie|db_|console) {
            deny all;

        location ~ ^/nextcloud/(?:index|pi-in-the-sky_php_info|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
            include fastcgi_params;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param HTTPS on;
            #Avoid sending the security headers twice
            fastcgi_param modHeadersAvailable true;
            fastcgi_param front_controller_active true;
            fastcgi_pass php-handler;
            fastcgi_intercept_errors on;
            fastcgi_request_buffering off;
            # Added to allow larger file uploads
            fastcgi_read_timeout 3600;
            #fastcgi_connect_timeout 2;
            #fastcgi_send_timeout 2;

        location ~ ^/nextcloud/(?:updater|ocs-provider)(?:$|/) {
            try_files $uri/ =404;
            index index.php;

        # Adding the cache control header for js and css files
        # Make sure it is BELOW the PHP block
        location ~* \.(?:css|js)$ {
            try_files $uri /nextcloud/index.php$uri$is_args$args;
            add_header Cache-Control "public, max-age=7200";
            # Add headers to serve security related headers  (It is intended
            # to have those duplicated to the ones above)
            # Before enabling Strict-Transport-Security headers please read
            # into this topic first.
            add_header Strict-Transport-Security "max-age=15768000; includeSubDomains” always;
            # preload;";
            add_header X-Content-Type-Options nosniff;
            add_header X-Frame-Options "SAMEORIGIN";
            add_header X-XSS-Protection "1; mode=block";
            add_header X-Robots-Tag none;
            add_header X-Download-Options noopen;
            add_header X-Permitted-Cross-Domain-Policies none;
            # Optional: Don't log access to assets
            access_log off;

        location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
            try_files $uri /nextcloud/index.php$uri$is_args$args;
            # Optional: Don't log access to other assets
            access_log off;


<IfModule mod_headers.c>
  <IfModule mod_setenvif.c>
    <IfModule mod_fcgid.c>
       SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
       RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    <IfModule mod_proxy_fcgi.c>
       SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1

  <IfModule mod_env.c>
    # Add security and privacy related headers
    Header set X-Content-Type-Options "nosniff"
    Header set X-XSS-Protection "1; mode=block"
    Header set X-Robots-Tag "none"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set X-Download-Options "noopen"
    Header set X-Permitted-Cross-Domain-Policies "none"
    SetEnv modHeadersAvailable true

  # Add cache control for CSS and JS files
  <FilesMatch "\.(css|js)$">
    Header set Cache-Control "max-age=7200, public"
<IfModule mod_php5.c>
  php_value upload_max_filesize 2G ####EDITED BY ME
  php_value post_max_size 2G ####EDITED BY ME
  php_value memory_limit 128M ####EDITED BY ME
  php_value mbstring.func_overload 0
  php_value always_populate_raw_post_data -1
  php_value default_charset 'UTF-8'
  php_value output_buffering 0 
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
<IfModule mod_php7.c>
  php_value upload_max_filesize 2G ####EDITED BY ME
  php_value post_max_size 2G ####EDITED BY ME
  php_value memory_limit 128M ####EDITED BY ME
  php_value mbstring.func_overload 0
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L]
  RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
  RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
  RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
  RewriteRule ^remote/(.*) remote.php [QSA,L]
  RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
  RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*
  RewriteRule ^(?:\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
<IfModule mod_mime.c>
  AddType image/svg+xml svg svgz
  AddEncoding gzip svgz
<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
  ModPagespeed Off

ErrorDocument 403 /nextcloud/core/templates/403.php
ErrorDocument 404 /nextcloud/core/templates/404.php


upload_max_filesize=2G ####EDITED BY ME
post_max_size=2G ####EDITED BY ME
memory_limit=128M ####EDITED BY ME


engine = On
short_open_tag = Off
precision = 14
output_buffering = 0 
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 17
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
disable_classes =
zend.enable_gc = On
expose_php = Off
max_execution_time = 3600 ####EDITED BY ME
max_input_time = -1 ####EDITED BY ME
memory_limit = 128M ####EDITED BY ME
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 2G ####EDITED BY ME
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_tmp_dir = /media/cloud_temp/temp ####EDITED BY ME
upload_max_filesize = 2G ####EDITED BY ME
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[CLI Server]
cli_server.color = On
pdo_mysql.cache_size = 2000
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On
sql.safe_mode = Off
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
bcmath.scale = 0
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1 = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
zend.assertions = -1
tidy.clean_output = Off
soap.wsdl_cache_limit = 5
ldap.max_links = -1


user = www-data
group = www-data
listen =;
listen.owner = www-data = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
request_terminate_timeout = 3600 ####EDITED BY ME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp