Question: Can't upload large files over PHP in Plesk: HTTP request length exceeds MaxRequestLen
Applicable to:Symptoms- Uploading large files through PHP apps to a Plesk domain fails: 500 Internal Server Error, 502 Bad Gateway
- The domain's Apache error log shows this message if nginx support is enabled:
mod_fcgid: HTTP request length ... (so far) exceeds MaxRequestLen (1310720)
- The domain's nginx error log shows this message:
- upstream prematurely closed connection while reading response header from upstream
CauseThe Apache parameters FcgidMaxRequestLen and FcgidMaxRequestInMem have too low of a value for the file's size.
ResolutionIndividual Domain 1.Log into Plesk
2.Go to Domains > example.com > Apache & Nginx settings
3.Add these lines to Additional directives for HTTP & HTTPS:
<IfModule mod_fcgid.c>
FcgidMaxRequestLen 1073741824
FcgidMaxRequestsPerProcess 100
FcgidProcessLifeTime 7200
FcgidIOTimeout 7200
FcgidMaxRequestInMem 1073741824
</IfModule>All DomainsThe following solution only works with FPM application served by Apache. For other handlers, use custom templates.
1.Connect to the server via SSH
Note: Contact the server administrator if there's no SSH access
2.Edit fcgid.conf:
- RHEL-based OS: /etc/httpd/conf.d/fcgid.conf
- Debian based OS: /etc/apache2/mods-available/fcgid.conf
3.Set the same value for FcgidMaxRequestLen and FcgidMaxRequestInMem in bytes. For example, 1073741824 for 1G.
4.Restart Apache:
Warning: Websites will be down for a short time while restarting Apache
For RHEL-based OS
# service httpd restart || service apache2 restart