Illuminate \ Http \ Exceptions \ PostTooLargeException

Illuminate \ Http \ Exceptions \ PostTooLargeException

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Illuminate \ Http \ Exceptions \ PostTooLargeException

When you encounter Illuminate\Http\Exceptions\PostTooLargeException in a Laravel application, it is often an immediate assumption that your server limits are misconfigured. The most common scenario involves checking php.ini and setting post_max_size to a high value, such as 10240M. However, seeing the exception persist despite this configuration indicates a misunderstanding of how PHP's request handling layers interact with Laravel's middleware stack.

The root cause is rarely that PHP itself cannot accept the data; it is usually that the upload limit was set too low in other critical files, or more commonly, the max_file_size directive within the application's own configuration is overriding your server settings. In Laravel, there are three distinct layers where this limit must be addressed to function correctly.

First, look at the php.ini file on your hosting environment or local machine. Setting post_max_size controls the maximum size of POST data that PHP will accept. If this value is lower than the actual file being uploaded, the request fails before it even reaches the application logic. However, simply changing this one file is insufficient. You must also ensure that upload_max_filesize in php.ini is equal to or greater than post_max_size. These two values work together: if upload_max_filesize is smaller than post_max_size, PHP will truncate the upload or reject it at the socket level regardless of the post_max_size setting.

Second, consider the Nginx or Apache configuration if you are using a web server that sits in front of PHP-FPM. If your application is behind a reverse proxy, the web server often has its own limit on request body size before passing it to PHP. For Nginx, this is controlled by client_max_body_size. If post_max_size in php.ini is set to 10GB but client_max_body_size in Nginx is left at the default 1MB (or explicitly set to a lower value), the web server will reject the request immediately, returning a 413 Payload Too Large error. This rejection triggers Laravel's exception handler to throw PostTooLargeException. You must ensure the web server limit is higher than or equal to both PHP directives.

Third, and most frequently overlooked in modern Laravel deployments, is the application-level configuration found in config/filesystems.php. Laravel uses the disk driver for file uploads, and this disk has a configurable max_file_size. If your php.ini allows 10GB but your .env file or config/filesystems.php sets disk.default.max_file_size to something small (or defaults to a restrictive value in some setups), Laravel will throw the exception upon attempting to process the upload. To resolve this, you need to set the max_file_size option in the disk configuration to match your intended limit.

// In config/filesystems.php or via .env
'disk' => [
    'driver' => 'local',
    'root'  => storage_path('app'),
    'max_file_size' => 10 * 1024 * 1024 * 1024, // 10GB in bytes
],

If you are using the wasabi or s3 driver, ensure that the underlying storage service (like AWS S3) has its own limits increased via environment variables, as S3 has a default limit of 5GB per object.

Finally, remember that increasing these limits comes with trade-offs. Larger uploads consume more memory in PHP-FPM. If memory_limit is not also increased alongside post_max_size, you risk encountering Allowed memory size exhausted errors during the upload process. Always verify that memory_limit in php.ini is sufficient to handle the largest file plus overhead. Additionally, while increasing limits solves the exception, it does not solve network latency or bandwidth constraints; a 10GB upload will still take significant time over standard connections.

For production environments where you need precise control over these settings without modifying global php.ini files, consider using .user.ini for local development or deploying custom PHP configurations via container orchestration tools like Docker or Kubernetes to ensure consistency across all layers of the stack.

Our network