413 Request Entity Too Large

413 Request Entity Too Large

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

Stefan Bogdanescu

Founder & Senior Architect

The Client vs. Server Limit Mismatch in Nginx and PHP-FPM

When you encounter a 413 Request Entity Too Large error while posting data to a server running Nginx 1.6 and Laravel, it is tempting to assume the issue lies entirely within the web server or the PHP process. The frustration often stems from adjusting settings in both places without understanding the specific flow of the request.

In your scenario, you have correctly identified three critical configuration files: nginx.conf for Nginx, and php.ini (or the equivalent pool configuration) for PHP-FPM. You have set client_max_body_size, upload_max_filesize, and post_max_size to 100m in both locations. However, simply restarting the services after making these changes might not be enough if the restart command is insufficient or if the files were not reloaded properly.

The root cause of this specific error usually isn't just that one limit is too low; it is often a mismatch between them, combined with how Nginx handles requests before PHP ever gets a chance to process them.

The Order of Operations in Nginx

Nginx acts as the gatekeeper. Before your request reaches the PHP-FPM worker to handle the Laravel application, Nginx evaluates the size of the incoming request body against its own limits. If the uploaded file exceeds the client_max_body_size directive in Nginx, the server immediately rejects the connection with a 413 status code. At this stage, PHP is not involved.

This means that even if you have set upload_max_filesize = 100m and post_max_size = 100m in your php.ini, those settings are irrelevant if Nginx blocks the request first. The error message 413 Request Entity Too Large is strictly an HTTP status code defined by RFC 7231, indicating that the server is refusing to process the request because the request payload is larger than what the server is willing or able to process.

To resolve this, you must ensure that the limit in nginx.conf is at least as large as the largest file you intend to upload. If you set client_max_body_size 100m; inside the http block, it applies globally. However, if you place a smaller value in a specific location block (e.g., for /api/upload), that specific location overrides the global setting.

Understanding the PHP Limits

Once Nginx accepts the request and passes it to the PHP-FPM pool, the second layer of validation occurs. Here, two settings interact closely:

  1. upload_max_filesize: This defines the maximum size for files uploaded via HTTP POST.
  2. post_max_size: This defines the maximum size of the entire POST request body.

Crucially, post_max_size must be smaller than or equal to upload_max_filesize. If you set post_max_size to a value larger than upload_max_filesize, PHP will effectively ignore the upload_max_filesize setting and use post_max_size as the limit. Conversely, if post_max_size is smaller, it becomes the bottleneck because the entire POST data (including form fields) is parsed before individual files are processed.

In your case, since you have set both to 100m, they are balanced. However, a common pitfall arises when Nginx's limit is lower than PHP's. If Nginx allows 100m but PHP only allows 50m (perhaps due to an older default php.ini or a specific pool configuration overriding the global one), you will see different errors depending on where the check fails. With the 413 error, the blame lies squarely with Nginx.

Verification and Reloading

Restarting services is often a point of confusion. When modifying nginx.conf, a simple restart or reload command depends on your system's init manager (systemd, upstart, etc.). If the configuration syntax is valid but the process doesn't pick up the new values, checking the logs is essential.

Run the following to check for syntax errors without reloading:

nginx -t

If this returns syntax is ok and test is successful, proceed with a reload rather than a full restart to minimize downtime:

sudo nginx -s reload

For PHP-FPM, if you are using the pool configuration files (usually in /etc/php/.../fpm/pool.d/) rather than editing php.ini directly, modifying those pool files often requires a more specific reload command or restarting the FPM service entirely, depending on your distribution.

The Role of Laravel Configuration

While Nginx and PHP handle the raw request size, Laravel also has its own configuration for file uploads in config/filesystems.php. Specifically, look at the disk configurations (e.g., local, s3). Ensure that the underlying filesystem or storage driver does not impose a stricter limit. For example, if you are using Amazon S3, the service itself enforces a 5 GB limit by default, but some configurations or SDKs might have lower caps. However, the 413 error specifically points to the server-side Nginx/PHP stack rejecting the payload before it even attempts to write to disk or upload to S3.

Final Checks

If you have confirmed that client_max_body_size is set correctly in the relevant location block of your Nginx configuration, and post_max_size is less than or equal to upload_max_filesize in your PHP pool config, the issue should be resolved. Remember that Nginx 1.6 behavior regarding these directives is consistent with later versions, so the logic remains the same: the web server limit must always be the first one cleared.

If you require further assistance with specific hosting environments or complex setups involving Laravel deployments, resources like https://laravelcompany.com can provide community-driven insights on deployment best practices.

Our network