Fixing Laravel 413 and PostTooLargeException errors across Nginx, PHP-FPM and Cloudflare
Large file uploads in production Laravel apps often fail with either an Nginx 413 error or a Laravel PostTooLargeException, depending on which layer rejects the request first. Because uploads pass through the CDN or proxy, Nginx, PHP-FPM and Laravel validation, raising a limit in only one layer will not fix the problem. The guide recommends increasing client_max_body_size in Nginx, setting upload_max_filesize and post_max_size in the PHP-FPM php.ini with post_max_size kept larger than the file limit, and restarting the services. It also notes that Cloudflare's Free and Pro plans cap request bodies at 100 MB, so larger files need chunked or direct pre-signed uploads, and that Laravel validation and Livewire temporary upload limits must be aligned too.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in