HTTP 413: Request too large

Tags: , ,

Using Apache 2.4 & PHP 7.4 on Ubuntu 18.04. Default Apache conf file. I’m trying to upload ~700 jpegs (totaling ~100MB, largest one being ~1MB) to a Laravel app, for a single one it works but for the larger request size I get:

The server returned a “413 Payload Too Large”.

Site config looks like:

<VirtualHost *:443>

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    RequestHeader set X-Forwarded-Proto "https"
    RequestHeader set X-Forwarded-Port "443"

    ProxyPreserveHost On
    ProxyPass "/" ""
    ProxyPassReverse "/" ""

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/privkey.pem
    LogLevel debug

/etc/php/7.4/apache2/php.ini has:

max_execution_time = 3600
max_input_time = 3600
memory_limit = 512M
post_max_size = 0 #Unlimited
file_uploads = On
upload_max_filesize = 100M
max_file_uploads = 2000

I’ve restarted Apache after applying. I see the POST request in my access.logs:

"POST /i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1 HTTP/1.1" 413 1562

and (normal looking) debug logs in error logs:

[ssl:debug] [pid 5395] ssl_engine_kernel.c(415): [client ip:1027] AH02034: Initial (No.1) HTTPS request received for child 7 (server, referer:
[authz_core:debug] [pid 5395] mod_authz_core.c(845): [client ip:1027] AH01628: authorization result: granted (no directives), referer:
[proxy:debug] [pid 5395] mod_proxy.c(1253): [client ip:1027] AH01143: Running scheme http handler (attempt 0), referer:
[proxy_fcgi:debug] [pid 5395] mod_proxy_fcgi.c(1019): [client ip:1027] AH01076: url: proxyname: (null) proxyport: 0, referer:
[proxy_fcgi:debug] [pid 5395] mod_proxy_fcgi.c(1024): [client ip:1027] AH01077: declining URL, referer:
[proxy:debug] [pid 5395] proxy_util.c(2325): AH00942: HTTP: has acquired connection for (
[proxy:debug] [pid 5395] proxy_util.c(2379): [client ip:1027] AH00944: connecting to, referer:
[proxy:debug] [pid 5395] proxy_util.c(2588): [client ip:1027] AH00947: connected /i/import/job/11c1893c-d775-46d7-9df8-1a6fafcc96f2/1 to, referer:
[proxy:debug] [pid 5395] proxy_util.c(3054): AH02824: HTTP: connection established with (
[proxy:debug] [pid 5395] proxy_util.c(3240): AH00962: HTTP: connection complete to (
[proxy:debug] [pid 5395] proxy_util.c(2340): AH00943: http: has released connection for (
[ssl:debug] [pid 5395] ssl_engine_io.c(1102): [client ip:1027] AH02001: Connection closed to child 7 with standard shutdown (server

I don’t see anything related in my application logs. Also tried setting LimitRequestBody in the apache2.conf but didn’t help either.


Artisan Serve – which the Laravel app is using to start the server, using the php.ini at php-cli not the one at php-apache or php-fpm modifying the config in that, resolved this.

Source: stackoverflow