Symptoms
-
Uploading large files over PHP (about 500 MB or more) to a website on a Plesk for Linux server fails with the following error in the log file
/var/www/vhosts/system/example.com/logs/proxy_error_log
:[error] 13840#0: *22012496 upstream prematurely closed connection while reading response header from upstream, client: 203.0.113.2, server: example.com, request: "POST /upload-files.php HTTP/1.1", upstream: http://203.0.113.2:7080/upload-file.php", host: "example.com", referrer: "http://example.com/upload-files.php"
-
PHP handler is set to FastCGI application by Apache in Domains > example.com > PHP Settings.
-
In Domains > example.com > PHP Settings, the parameters
max_input_time
,post_max_size
, andupload_max_filesize
are set to the sufficient values. -
The nginx parameters
client_max_body_size
,proxy_connect_timeout
,proxy_send_timeout
, andproxy_read_timeout
are also set to the sufficient values (either in/etc/nginx/nginx.conf
or in Domains > example.com > Apache & nginx Settings > Additional nginx directives). -
The Apache parameters
FcgidMaxRequestLen
(in Domains > example.com > Apache & nginx Settings > Additional Apache directives),FcgidIOTimeout
(in/etc/apache2/mods-available/fcgid.conf
or/etc/httpd/conf.d/fcgid.conf
) are also set to the sufficient values. -
The Apache parameter
FcgidBusyTimeout
is not overrided in any configuration files.
Cause
The default value – 300 seconds – of the parameter FcgidBusyTimeout
is used, limiting the maximum time for handling FastCGI request to 5 minutes.
Resolution
-
Connect to the server via SSH
-
Open the configuration file
/etc/apache2/mods-available/fcgid.conf
(on Debian or Ubuntu) or/etc/httpd/conf.d/fcgid.conf
(on RHEL-based operating systems) in the text editor -
Inside the section
<IfModule mod_fcgid.c>
, define the parameterFcgidBusyTimeout
in seconds:<IfModule mod_fcgid.c>
..........
FcgidBusyTimeout 1000
..........
</IfModule> -
Restart Apache to apply changes:
-
On Debian or Ubuntu:
# service apache2 restart
-
On RHEL-based operating systems:
# service httpd restart
-
Note: Repeat steps 3 and 4 in case the issue persist. Alternatively, consider to change to PHP-FPM going to Domains > example.com > PHP Setting