Articles in this section

Upload of a big file on websites hosted in Plesk fails: client intended to send too large body

Plesk for Linux kb: technical

Applicable to:

  • Plesk for Linux

Symptoms

  • Unable to upload a file using a web application or webmail, the following error is shown:

    An error occurred!
    File upload failed

  • When uploading a big file via the WP dashboard > Media > Add New Media File interface (for example, a video file with a size of 2.2 GB), the following error is shown:

    CONFIG_TEXT: Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.

    In connection with this error, entries that are similar to the following are recorded in nginx or Apache error logs for the domain:

    CONFIG_TEXT: Error 203.0.113.2 2043720#0: *789 client intended to send too large body: 2362,232013 bytes nginx error

    CONFIG_TEXT: Warning 203.0.113.2 mod_fcgid: HTTP request length 134224506 (so far) exceeds MaxRequestLen (134217728), referer: https://example.com/wp-admin/upload.php Apache error

  • The following error can be seen in the browser's console:

    413 Request Entity Too Large

  • Uploading of big size file fails with the following error in /var/www/vhosts/system/example.com/logs/proxy_error_log or /var/log/nginx/error.log file:

    CONFIG_TEXT: client intended to send too large body: 163625628 bytes, client: 203.0.113.2, server: example.com, request: "POST /attachments/uploading.json?hash=bb192e03d44f11110881f1c148ef629&content_type=resource_version&key=resource HTTP/1.1", host: "203.0.113.2", referrer: "https://203.0.113.2/resources/add?resource_category_id=13"

Cause

The current web server limits are insufficient for the file size and are preventing a larger file from being uploaded via PHP, due to which they need to be increased.

Resolution

Note: For the WordPress script specifically, you can resolve the big file upload issue for the default Media Library upload feature of WP itself by adding the chunked file upload capability, which is done by simply installing the following plugin:
Big File Uploads – Increase Maximum File Upload Size – WordPress plugin

  1. Log into Plesk
  2. Go to Domains > example.com > Dashboard > PHP in order to determine which of the following web server, PHP handler (and PHP version) combinations is being used for the affected domain:
    FPM application served by Apache
    FPM application served by nginx
    FastCGI served by Apache

  3. Depending on the situation for the affected domain, use the steps in the corresponding section:
FPM application served by Apache

Click on a section to expand

Solution per domain

Note: The steps below are valid when Nginx proxies requests to Apache

1. Log into Plesk
2. Go to Domains > example.com > Dashboard > PHP
3. Set the post_max_size and upload_max_filesize to a value that is sufficient for the file that you are trying to upload (For example 3G).
4. Scroll down and press Apply
5. Go to Domains > example.com > Hosting & DNS > Apache & nginx
6. Set the Maximum allowed HTTP request body size (also known as client_max_body_size) to the same value that you used for post_max_size and upload_max_filesize (for example 3GB)

Solution for all domains using a certain PHP version and Service Plan

1. Log into Plesk

2. Adjust the following settings of of the PHP version and PHP handler used by the domains in Tools & Settings > PHP Settings > X.X.XX FPM application > php.ini tab:

CONFIG_TEXT: post_max_size 3G
upload_max_filesize 3G

3. Go to Service Plans > SERVICE_PLAN_NAME > Web Server > nginx settings

4. Set the Maximum allowed HTTP request body size (also known as client_max_body_size) to the same value that you used for post_max_size and upload_max_filesize (for example 3GB)
5. Scroll down and press OK

FPM application served by nginx

Click on a section to expand

Solution per domain

1. Log into Plesk
2. Go to Domains > example.com > Dashboard > PHP
3. Set the post_max_size and upload_max_filesize to a value that is sufficient for the file that you are trying to upload (For example 3G).
4. Scroll down and press Apply
5. Go to Domains > example.com > Hosting & DNS > Apache & nginx
6. Set the Maximum allowed HTTP request body size (also known as client_max_body_size) to the same value that you used for post_max_size and upload_max_filesize (for example 3GB)

Solution for all domains using a certain PHP version and Service Plan

1. Log into Plesk

2. Adjust the following settings of of the PHP version and PHP handler used by the domains in Tools & Settings > PHP Settings > X.X.XX FPM application > php.ini tab:

CONFIG_TEXT: post_max_size 3G
upload_max_filesize 3G

3. Go to Service Plans > SERVICE_PLAN_NAME > Web Server > nginx settings

4. Set the Maximum allowed HTTP request body size (also known as client_max_body_size) to the same value that you used for post_max_size and upload_max_filesize (for example 3GB)
5. Scroll down and press OK

FastCGI served by Apache

Click on a section to expand

Solution per domain

On Plesk, the default global template settings that override other Apache limits are the following:

# root@server:~# grep -ri MaxRequestLen /usr/local/psa/admin/conf/templates/default/
/usr/local/psa/admin/conf/templates/default/webmail/roundcube.php: FcgidMaxRequestLen 134217728
/usr/local/psa/admin/conf/templates/default/webmail/horde.php: FcgidMaxRequestLen 134217728
/usr/local/psa/admin/conf/templates/default/domain/domainVirtualHost.php: FcgidMaxRequestLen 134217728

Due to this, the recommended solution is to change the PHP handler for the domain to FPM application served by Apache, because that way the global default template Apache setting FcgidMaxRequestLen would not need to be updated by creating custom template files for the entire server

After The PHP handler has been changed, follow these steps:

Note: The steps below are valid when Nginx proxies requests to Apache

1. Log into Plesk
2. Go to Domains > example.com > Dashboard > PHP
3. Set the post_max_size and upload_max_filesize to a value that is sufficient for the file that you are trying to upload (For example 3G).
4. Scroll down and press Apply
5. Go to Domains > example.com > Hosting & DNS > Apache & nginx
6. Set the Maximum allowed HTTP request body size (also known as client_max_body_size) to the same value that you used for post_max_size and upload_max_filesize (for example 3GB)

Solution for all domains using a certain PHP version and Service Plan


On Plesk, the default global template settings that override other Apache limits are the following:

# root@server:~# grep -ri MaxRequestLen /usr/local/psa/admin/conf/templates/default/
/usr/local/psa/admin/conf/templates/default/webmail/roundcube.php: FcgidMaxRequestLen 134217728
/usr/local/psa/admin/conf/templates/default/webmail/horde.php: FcgidMaxRequestLen 134217728
/usr/local/psa/admin/conf/templates/default/domain/domainVirtualHost.php: FcgidMaxRequestLen 134217728

Due to this, the recommended solution is to change the PHP handler for the domain to FPM application served by Apache, because that way the global default template Apache setting FcgidMaxRequestLen would not need to be updated by creating custom template files for the entire server.

After The PHP handler has been changed, follow these steps:

1. Log into Plesk

2. Adjust the following settings of of the PHP version and PHP handler used by the domains in Tools & Settings > PHP Settings > X.X.XX FPM application > php.ini tab:

CONFIG_TEXT: post_max_size 3G
upload_max_filesize 3G

3. Go to Service Plans > SERVICE_PLAN_NAME > Web Server > nginx settings

4. Set the Maximum allowed HTTP request body size (also known as client_max_body_size) to the same value that you used for post_max_size and upload_max_filesize (for example 3GB)
5. Scroll down and press OK

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.