Livewire uploads work locally but fail behind nginx on the server
413 Request Entity Too LargeShort answer
Three separate limits stop a large upload, and a local dev server hides two of them. nginx rejects bodies over 1 MB by default, PHP accepts only 2 MB per file and 8 MB per request by default, and Livewire validates temporary uploads against a 12 MB rule. Raise each one to match, reload the services, and test with a file near your real maximum.
Fix it fast
1Find out which cause you have
Upload a file in the browser with the network tab open and read the status of the upload request. A 413 comes from nginx. Anything else means PHP or Livewire.
sudo tail -n 20 /var/log/nginx/error.log2Match what you see, then jump to its fix
- 1
413 Request Entity Too Large in the browser's network tabnginx rejects the request body (default 1 MB)Fix - 2
The request reaches PHP but the upload is empty, or only files over 2 MB fail after nginx was fixedPHP limits are lower than the fileFix - 3
nginx and PHP accept the request, but a file over 12 MB fails validationLivewire's own temporary-upload rule (12 MB)Fix
- 1
What does the error look like?
413 Request Entity Too Large$_POST and $_FILES are empty (PHP discards a body over post_max_size)Small files upload, larger ones fail
Cause 1 of 3
nginx rejects the request body (default 1 MB)
1Check
client_max_body_size defaults to 1m. When the body is bigger, nginx answers 413 before PHP sees the request.
grep -R "client_max_body_size" /etc/nginx/2Fix
Set a limit above your largest upload, in the http, server or location block that serves the app. Then test the config and reload nginx.
server {
client_max_body_size 20m;
}3Verify
Reload nginx and upload the file that failed.
sudo nginx -t && sudo systemctl reload nginxConfirmed by nginx.org
Cause 2 of 3
PHP limits are lower than the file
1Check
upload_max_filesize defaults to 2M and post_max_size to 8M. If the whole request is bigger than post_max_size, PHP leaves $_POST and $_FILES empty. post_max_size must be larger than upload_max_filesize. Read the values the web service uses, not only the command line: the CLI can load a different php.ini.
php -i | grep -E 'upload_max_filesize|post_max_size'2Fix
Raise both values in the php.ini that PHP-FPM loads (find it in the phpinfo() output of a page served by the site), keeping post_max_size larger, then restart PHP-FPM.
upload_max_filesize = 20M
post_max_size = 25M
; sudo systemctl restart php8.3-fpm3Verify
Upload a file just under 20 MB and confirm it is accepted.
sudo systemctl restart php8.3-fpmConfirmed by php.net
Cause 3 of 3
Livewire's own temporary-upload rule (12 MB)
1Check
Livewire validates every temporary upload with a default rule that allows files up to 12288 kilobytes. Your component's own rules (for example max:1024) are checked later and are separate.
grep -n "temporary_file_upload" -A8 config/livewire.php2Fix
Publish the config if the file does not exist, then set a rule that matches your limits, and keep it below the nginx and PHP values.
php artisan livewire:config
// config/livewire.php
'temporary_file_upload' => [
'rules' => 'file|mimes:png,jpg,pdf|max:20480',
],3Verify
Clear the cached config and upload a file between 12 MB and 20 MB.
php artisan config:clearConfirmed by livewire.laravel.com
How do I stop it coming back?
- Write the three limits (nginx, PHP, Livewire) next to each other in your deploy notes and change them together.
- Keep post_max_size larger than upload_max_filesize, and the nginx limit larger than both.
- After any change to the nginx or PHP-FPM config, reload the service, not only the app.
- Test every deploy with a file near your largest allowed size, not a 100 KB image.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
- EZ EstimaterConstruction quoting and job tracking for contractors, on a Laravel and Firebase stack.
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
Related fixes
Back end
Laravel file upload returns 413 behind nginx
413 Content Too Large
A 413 means a limit refused the request body before Laravel could use it.
3 causes, each with a fixBack end
Laravel routes return 404 or throw NotFoundHttpException
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
A 404 means Laravel found no route for that URL, or the request never reached Laravel at all.
3 causes, each with a fixBack end
PHP stops the script after 30 seconds
Symfony\Component\ErrorHandler\Error\FatalError: Maximum execution time of 60 seconds exceeded
PHP ends a script that runs past max_execution_time (30 seconds by default for web requests).
5 causes, each with a fixBack end
Chrome shows net::ERR_INCOMPLETE_CHUNKED_ENCODING on a PHP page
The page loads partly, then the response stops
The browser got a chunked response that ended before its final zero-length chunk, so the connection closed mid-page.
2 causes, each with a fixBack end
CodeIgniter works locally but every page is 404 on the live server
The requested URL was not found on this server.
A 404 on the live server comes from one of four places: the document root is not the public folder, Apache ignores .htaccess or nginx has no try_files rule, the route is not defined because auto routing is off, or the controller file name differs from its class in case.
5 causes, each with a fixBack end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fix