Nextcloud: Upload Size Limit — Fix
The Problem
Nextcloud rejects file uploads above a certain size. Users see errors like:
- “Upload failed. Could not upload file because the file is too large”
- “Request Entity Too Large” (413 error)
- Upload progress bar reaches 100% but the file disappears
- Desktop client shows sync errors for large files
The default upload limit depends on your PHP configuration — typically 2 MB or 512 MB. When using a reverse proxy, the proxy may impose its own limit.
The Cause
Four layers can each impose upload size limits:
| Layer | Default Limit | Config Location |
|---|---|---|
| PHP | 2 MB (upload_max_filesize) | php.ini or .htaccess |
| PHP | 8 MB (post_max_size) | php.ini or .htaccess |
| Nextcloud | 512 MB (chunked upload) | Admin settings |
| Web server (nginx) | 1 MB (client_max_body_size) | nginx.conf |
| Reverse proxy | Varies | Proxy config |
The most restrictive layer wins. You need to increase limits at every layer.
The Fix
Method 1: PHP Configuration (Docker)
For the official Nextcloud Docker image, create a custom PHP config:
# Create custom PHP config
cat > /path/to/nextcloud/config/upload.ini << 'EOF'
upload_max_filesize = 16G
post_max_size = 16G
max_input_time = 3600
max_execution_time = 3600
memory_limit = 512M
EOF
Mount it in Docker Compose:
services:
nextcloud:
image: nextcloud:33.0.0
volumes:
- nextcloud_data:/var/www/html
- ./upload.ini:/usr/local/etc/php/conf.d/upload.ini:ro
Restart the container:
docker compose restart nextcloud
Method 2: PHP Configuration (Non-Docker)
Edit the PHP config file (location depends on your OS):
# Find the active php.ini
php -i | grep "php.ini"
# Edit it
sudo nano /etc/php/8.3/fpm/php.ini
Change these values:
upload_max_filesize = 16G
post_max_size = 16G
max_input_time = 3600
max_execution_time = 3600
memory_limit = 512M
Alternatively, add to Nextcloud’s .htaccess file:
php_value upload_max_filesize 16G
php_value post_max_size 16G
php_value max_input_time 3600
php_value max_execution_time 3600
Restart PHP-FPM:
sudo systemctl restart php8.3-fpm
Method 3: Nginx Reverse Proxy
If you’re using nginx as a reverse proxy in front of Nextcloud:
server {
listen 443 ssl;
server_name cloud.yourdomain.com;
client_max_body_size 16G; # Maximum upload size
client_body_timeout 3600s; # Time to wait for request body
proxy_read_timeout 3600s; # Time to wait for proxy response
proxy_connect_timeout 3600s;
location / {
proxy_pass http://nextcloud:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_request_buffering off; # Stream uploads directly, don't buffer
}
}
Reload nginx:
sudo nginx -t && sudo systemctl reload nginx
Method 4: Nginx Proxy Manager
In Nginx Proxy Manager:
- Go to your Nextcloud proxy host
- Click the Advanced tab
- Add this custom configuration:
client_max_body_size 16G;
proxy_request_buffering off;
client_body_timeout 3600s;
Method 5: Apache Reverse Proxy
<VirtualHost *:443>
ServerName cloud.yourdomain.com
ProxyPass / http://nextcloud:80/
ProxyPassReverse / http://nextcloud:80/
# Increase upload limit
LimitRequestBody 17179869184
ProxyTimeout 3600
TimeOut 3600
</VirtualHost>
Method 6: Nextcloud Admin Settings
- Log into Nextcloud as admin
- Go to Administration Settings > Basic Settings
- Under Upload, check the current chunked upload limit
- Nextcloud uses chunked uploads (10 MB chunks by default), so the PHP limit mainly affects the web UI uploader rather than desktop/mobile clients
Verify the Fix
After applying changes, verify the effective limits:
# Check PHP settings inside the Docker container
docker exec nextcloud php -i | grep -E "upload_max_filesize|post_max_size|memory_limit"
Expected output:
upload_max_filesize => 16G => 16G
post_max_size => 16G => 16G
memory_limit => 512M => 512M
Test by uploading a file larger than the previous limit.
Prevention
- Set upload limits during initial deployment — add the custom PHP config to your Docker Compose from the start
- Use the desktop client for large files — Nextcloud desktop clients use chunked uploads that bypass PHP limits
- Set
proxy_request_buffering offin nginx to prevent the proxy from buffering the entire upload in memory before forwarding - Monitor disk space — large uploads can fill your volume unexpectedly; set up disk usage alerts
Related
Get self-hosting tips in your inbox
Get the Docker Compose configs, hardware picks, and setup shortcuts we don't put in articles. Weekly. No spam.
Comments