Question
Why do I receive a "408 Request Timeout" error when uploading large files? The Apache error log and the site's error log don't indicate what limit is being exceeded. How can I resolve this problem?
Answer
In most cases, this error occurs due to exceeding the RequestReadTimeout directive, which is part of the mod_reqtimeout Apache module. The default value for this directive in Apache 2.4 is:
RequestReadTimeout handshake=0 header=20-40,MinRate=500 body=20,MinRate=500
This can be interpreted as:
- No limit on receiving TLS handshake
- Allow at least 20 seconds to receive request headers, but no more than 40
- Allow at least 20 seconds to receive the request body. If the client sends data, increase the timeout by 1 second for every 500 bytes received.
By default, this setting is not defined in the Apache configuration file on cPanel servers:
[root@samtest ~]# grep -i requestreadtimeout /etc/apache2/conf/httpd.conf
[root@samtest ~]#
To modify the Apache configuration on a cPanel server, the Apache Include Editor should be used:
Where would I add customizations to Apache?
In the Include Editor, select the Pre Main include for All Versions and add the following, modified to meet your requirements:
<IfModule mod_reqtimeout.c>
RequestReadTimeout handshake=0 header=20-40,MinRate=500 body=20,MinRate=500
</IfModule>
NOTE: Increasing this setting significantly without careful consideration and testing is not recommended. Opening your Apache web server to long-running requests may make it vulnerable to abuse and attacks such as the Slowloris attack:
How to Mitigate Slowloris Attacks
As this issue is often encountered when uploading large files via a PHP form, the best solution would be to ensure your client device is using a fast and reliable network, or upload the files via an alternative method such as FTP:
Comments
0 comments
Article is closed for comments.