November 27, 2026
Why large file uploads fail (and how to fix it)
Four limits that sit between the browser and your app, and the one fix that gets around all of them

By Jason F
2 min read
Small files upload fine, then someone tries a 300 MB video and gets a 413, a spinner that never ends, or a connection reset. The app code usually is not the problem. Somewhere between the browser and your app there is a limit, and most of them are defaults nobody chose on purpose.
Note: this story was written with the help of AI.
I ran into every one of these while building a video host, so here is the list I wish I had at the start.
1. The reverse proxy: nginx allows 1 MB
If nginx sits in front of your app, its client_max_body_size defaults to 1m. Anything bigger gets a 413 before your app sees a single byte. Raise it in the server or location block that handles uploads:
location /upload {
client_max_body_size 200m;
proxy_pass http://127.0.0.1:8000;
}location /upload {
client_max_body_size 200m;
proxy_pass http://127.0.0.1:8000;
}While you are there, look at client_body_timeout. It defaults to 60 seconds, but it measures the gap between two reads, not the whole upload, so it mostly bites on very unstable connections.
2. PHP: 2 MB per file, 8 MB per request
Stock php.ini ships with upload_max_filesize = 2M and post_max_size = 8M. The second one is the sneaky one: if the whole request is bigger than post_max_size, PHP throws the body away and your script sees empty $_POST and $_FILES, with no clear error. Raise both, and keep post_max_size a bit larger than the file limit.
3. Cloudflare: 100 MB on Free and Pro
This one cannot be configured away. Cloudflare's docs list a maximum request body of 100 MB on the Free and Pro plans and 200 MB on Business. A bigger request is answered with a 413 at the edge and never reaches your server. Cloudflare's own suggestions are to split the upload into smaller chunks, send it through a hostname that is not proxied, or upgrade the plan.
4. The phone itself
On mobile, a long upload competes with everything else. If the user switches apps or the screen locks, the browser may pause or drop the page, and a single 500 MB request starts again from zero. On a train or weak WiFi, one dropped connection is enough to lose the whole thing.
The fix that covers all four: chunked uploads
Instead of one huge request, the browser slices the file and sends it in pieces of a few megabytes each:
const CHUNK = 8 * 1024 * 1024; // 8 MB, far below every limit above
for (let offset = 0; offset < file.size; offset += CHUNK) {
const part = file.slice(offset, offset + CHUNK);
await sendWithRetry(uploadId, offset, part); // retry this piece, not the file
}const CHUNK = 8 * 1024 * 1024; // 8 MB, far below every limit above
for (let offset = 0; offset < file.size; offset += CHUNK) {
const part = file.slice(offset, offset + CHUNK);
await sendWithRetry(uploadId, offset, part); // retry this piece, not the file
}Each request is small, so nginx, PHP and Cloudflare all let it through with sensible settings. If a piece fails, only that piece is sent again. And if the server remembers how many bytes it already has, the browser can ask after a reload and continue where it stopped, which is what makes uploads from phones bearable.
The server side is less work than it sounds: create an upload ID, append each chunk at its offset after checking that the offset matches what you already stored, and mark the upload complete when the last byte arrives. I wrote down a full version of that in Flask, without any upload library, in Resumable chunked uploads in Flask without a library.
A quick checklist
- 413 straight away: nginx
client_max_body_size, or Cloudflare if the file is over 100 MB. - Upload "works" but the file is missing: PHP
post_max_size. - Fails after a while on phones but not on desktop: connection drops, use chunks with retries.
- Fails at the same size every time: there is a hard limit somewhere, check each layer from the outside in.
Disclosure: the video host I mentioned is Vidlify, which I build. Uploads there go up in small pieces, and a piece that fails because the connection dropped is retried up to five times, for exactly these reasons. If you just need to get a big video to someone without setting any of this up, it is free to use.