The POST data is too large
The request body is larger than PHP's post_max_size, so Laravel answers 413. Raise post_max_size, upload_max_filesize and the web server limit together.
- Message
- The POST data is too large.
- Exception
- Illuminate\Http\Exceptions\PostTooLargeException
What it means
The request body is bigger than PHP's post_max_size setting. Laravel's global ValidatePostSize middleware compares the request's Content-Length with that setting and throws PostTooLargeException, status 413, before any route or validation runs. PHP has already dropped the body: $_POST and $_FILES are empty.
Why it happens
- A form or upload is larger than
post_max_size, which defaults to8M. The limit counts the whole body, so five files of 1.8 MB each exceed it together. upload_max_filesizewas raised andpost_max_sizewas not. The PHP manual sayspost_max_sizemust be larger.- The setting was changed for the wrong PHP: PHP-FPM and the command line can read different ini files.
php -d post_max_size=100M artisan servedoes not help either, because the dev server runs in a new PHP process without the-doption.
Two neighbours look similar:
- nginx answers "413 Request Entity Too Large" itself when the body exceeds
client_max_body_size, default1m. PHP never runs; nginx's error log says "client intended to send too large body". - A file over
upload_max_filesizebut underpost_max_sizereaches Laravel as a failed upload:$request->hasFile('doc')is false, and afilerule fails with "The doc failed to upload.", a normal validation error.
How to fix it
The limits exist so that one request cannot tie up a PHP worker, memory and temporary disk space. Raise them only as far as the largest legitimate upload, with post_max_size above upload_max_filesize. In the php.ini that PHP-FPM loads (php-fpm -i | grep 'Loaded Configuration File' shows it; the binary may be named php-fpm8.4 or similar), or for the command line (php --ini):
upload_max_filesize = 20M
post_max_size = 25M
In a PHP-FPM pool file, the same settings look like this:
php_admin_value[upload_max_filesize] = 20M
php_admin_value[post_max_size] = 25M
In nginx, raise client_max_body_size for the upload route only, not the whole http block. That location must pass the request to PHP itself: one that hands over with try_files ends in your PHP location, whose limit then applies. Copy fastcgi_pass from your PHP location:
location = /documents/upload {
client_max_body_size 25m;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
}
Reload PHP-FPM and nginx afterwards. For php artisan serve, change the php.ini that php --ini names and restart it.
Inside the limits, give a clear message instead of a failed upload; max counts kilobytes for files:
$request->validate([
'doc' => ['required', 'file', 'max:20480'],
]);
For your own 413 page, add resources/views/errors/413.blade.php. It renders before the web middleware starts the session, so it must not rely on auth() or the session: a logged-in user appeared logged out there in the test, and $errors is always empty.
Find it in production
The visitor gets a 413 page titled "An Error Occurred: Content Too Large", or {"message": "The POST data is too large."} for a JSON request. Laravel does not report this exception: PostTooLargeException extends HttpException, which is on the handler's internalDontReport list, so nothing reaches storage/logs/laravel.log. Look for 413 responses in your web server's access log. PHP also writes a warning to its own error log with the size that was sent; a test with post_max_size = 2M logged "POST Content-Length of 3000215 bytes exceeds the limit of 2097152 bytes". A 413 from nginx itself shows up only in nginx's logs.
Reproduced on Laravel 13.45, PHP 8.5, nginx 1.31, 5 December 2026.
Related
Start monitoring today
Websites go down and code throws errors. Ranetrace tells you when it happens to yours, why it matters and what to do next.