What is the 413 Request Entity Too Large error, how to fix it and avoid it
The 413 Request Entity Too Large error means the server knows what the client is asking for but refuses to process the request because it’s too big. This error message usually appears when uploading large files or submitting data-heavy forms.
If you can’t break down large data into smaller parts to reduce its size before uploading, you’ll have to increase the server’s maximum upload size limit.
This article will explore different methods of adjusting the maximum file upload size in WordPress. We’ll also provide tips to prevent the 413 Request Entity Too Large error.
What causes 413 Request Entity Too Large error
Your web host will typically set a server limit to prevent slow performance or downtime when handling back end operations. These limits are usually sufficient for basic tasks like posting an article.
However, some website features might cause users to send larger amounts of data. If the requested resource or uploaded file exceeds the server’s limit, the server will terminate the connection and return the 413 Request Entity Too Large error message.
Insufficient server resources are another common cause of this HTTP status code, especially during high traffic. When too many users upload files to the server at the same time, all the requests overload the server.
Incorrect file permissions can trigger the error message by preventing the web server from accessing necessary files or directories. These restrictive permissions might hinder the server from processing large requests or uploads properly, causing the error.
Error code | Content too large |
Error type | Client error |
Error variations | 413 Request Entity Too LargeHTTP Error 413413: Payload Too Large |
Error causes | Large file uploadsIncorrect server configurationInsufficient server resourcesIncorrect file permissions |
How to fix 413 Request Entity Too Large error in WordPress
Now that you know what could trigger the 413 Request Entity Too Large error, let’s explore four methods to troubleshoot it, starting with the simplest.
As some methods require modifying your WordPress files, remember to back up your website. Additionally, ensure you have administrator access to your web server and files.
1. Reset file permissions
If incorrect file permissions cause the HTTP error, resetting them should fix it.
Hostinger users can easily do so from hPanel. Navigate to Websites → Advanced → Fix File Ownership, check the box confirming you want to reset file permissions, and then hit Execute.
Fixing file ownership will reset permissions to the following values:
- 644 for files ‒ the owner can read and write, while the group and others can only read.
- 755 for folders ‒ the owner can read, write, and execute, while the group and others can only read and execute.
Alternatively, change your file permission settings using your hosting provider’s File Manager or an FTP client like FileZilla.
Here’s how to do it using Hostinger’s File Manager:
- Go to Websites → Dashboard and select File manager.
- Right-click on your root directory (public_html) and choose Permissions.
- Check all the boxes except the writing permission for the group and others. Selecting Recursive will set the same permissions for the content inside folders. Hit Update.
- Verify the permissions for the following files and folders within your root folder:
- 755 ‒ wp-content folder and Uploads inside the former.
- 644 ‒ all files within the root folder, especially configuration files like .htaccess and wp-config.php.
Check out our guide on changing file permissions in Linux.
2. Increase the PHP upload size limit via hPanel
The second method to fix the 413 Request Entity Too Large error is to increase the PHP maximum upload file size limits. They determine the largest file size that users can upload, the maximum data sent in a single request, and the memory usage allocated for handling large uploads.
The default limit varies by hosting provider but is often around 128 MB. Raising this limit allows your web server to handle larger file uploads, potentially resolving the 413 status code.
Hostinger users can modify maximum file upload size limits from hPanel. Here’s how:
- Go to Websites → Advanced → PHP Configuration from the hPanel dashboard.
- Open the PHP Options tab, containing your website’s PHP configuration settings.
- Scroll down to the memoryLimit field and increase the script’s maximum memory usage. In this example, our Cloud Professional hosting plan offers up to 6144 MB.
- Next, locate the postMaxSize field and adjust the maximum size allowed for all requests, including file uploads. Ideally, the value should be smaller than the memory limit to ensure the server can handle multiple requests and tasks that need extra memory.
- Finally, set the new maximum file upload size within the uploadMaxFilesize field. Make sure the value is lower than postMaxSize to avoid errors when uploading files.
- Hit Save to confirm the changes.
3. Modify the functions.php file
Non-Hostinger users can increase the file upload size limit by modifying the functions.php file. This theme functions file defines a WordPress website’s functionality with rules, so you can add new code to adjust the maximum request and file size limits.
Since the functions.php file resets after updates, make sure to modify the functions file within your child theme instead. If your theme doesn’t have one, follow our guide on creating a new WordPress child theme.
Follow these steps to modify your theme’s functions.php file using Hostinger’s File Manager:
- Go to Websites → Dashboard and select File manager.
- Open wp-content → themes within your root directory. Locate your child theme and double-click the functions.php file to edit it.
- Find the lines containing upload_max_size, post_max_size, and max_execution_time parameters and increase their value. If you can’t find these rules, add the following code snippet to the bottom of the file:
@ini_set( 'upload_max_size' , '256M' );
@ini_set( 'post_max_size', '256M');
@ini_set( 'max_execution_time', '300' );
Changing the maximum execution time (max_execution_time) doesn’t directly resolve the 413 error. However, it can help in instances where large file uploads or data processing takes longer to complete, preventing timeout errors during these processes.
- Save the changes and check whether your file uploads successfully. If the 413 Request Entity Too Large error code persists, increase the values slightly or try the next methods.
4. Modify the .htaccess file
Another way to change the file upload size limit in WordPress is by editing the .htaccess file. This core WordPress file contains your web server’s configurations, including authorization, caching, and optimization.
Here’s how:
- Open your WordPress root directory using a File Manager or an FTP client.
- Double-click the .htaccess file to edit it. If you can’t find it, check our guide for steps to locate or create an .htaccess file.
- Add the following code snippet below the # END WordPress line:
php_value upload_max_filesize 256M
php_value post_max_size 256M
php_value max_execution_time 600
php_value max_input_time 600
Like maximum execution time, changing the maximum time for parsing input data (max_input_time) helps ensure that long-running uploads and data processing tasks don’t time out.
- Save the changes and check whether it fixes the error.
5. Modify NGINX configuration
Modifying the web server configuration also works for troubleshooting WordPress sites hosted on virtual private servers.
The file upload size limit varies depending on the web server software used. In NGINX servers, the client_max_body_size setting controls the maximum file upload size. To increase this limit, access the nginx.conf file via an SSH client like PuTTY or Terminal and edit the server settings using a text editor like Vi. Hostinger users can find their login credentials in the SSH access tab in the VPS overview menu.
Follow these steps to change your NGINX server configuration for troubleshooting the 413 error code:
- Once connected to your VPS, enter the following command in your Terminal to open the configuration file using Vi:
vi /etc/nginx/nginx.conf
- Enter these lines to change the maximum request body size that the server allows. We will set it to 8 MB as an example, so make sure to adjust it as needed:
# set client body size to 8M
# client_max_body_size 8M;
- Save and close the file by entering :wq and hitting Enter. Return to the main Terminal interface and restart NGINX to apply the changes by entering the following command:
nginx -s reload
For websites hosted on an Apache server, follow the same steps to modify the LimitRequestBody parameter’s value in the httpd.conf file.
Try reuploading files to your website to check if the 413 error is resolved.
How to avoid 413 Request Entity Too Large error
Even if it seems harmless, the 413 Request Entity Too Large error can hurt the user experience by interrupting file uploads and form submissions. After troubleshooting the error code, take these measures to prevent it from happening again.
Optimize file sizes
Compressing large files like images and videos before uploading them helps reduce the chances of exceeding the server’s size limits and triggering the error.
Common image optimization techniques like lossy and lossless compression let you reduce file sizes for faster web performance. Install image optimization plugins like WP Smush to automate compression.
Meanwhile, tools like HandBrake and DaVinci Resolve can help with video compression without compromising quality.
Audit server settings regularly
When you add a new function that sends large requests, adjust your server’s configuration settings to ensure they can handle them. Better yet, always test new features in a WordPress staging environment to avoid errors affecting your live website.
Hostinger users on WordPress Business and cloud hosting plans can quickly set up a staging website from the hosting control panel. Go to Websites → WordPress → Staging and select Create staging. The process takes several minutes to complete and doesn’t require coding.
Enable chunked uploads
Chunked uploading breaks a file into smaller parts, helping the server manage large files better and avoid the maximum request size limit. This method also enhances the reliability of your upload process.
The easiest way to enable this feature is by installing a WordPress file upload plugin like Big File Uploads. If you know how to code, integrating the FileReader API and a JavaScript library into your WordPress site offers more flexibility in configuring the settings.
Use a Content Delivery Network (CDN)
A CDN offloads traffic by caching and serving content from servers around the world. Caching stores copies of your site’s files closer to users, reducing server load and minimizing errors related to large requests. It also improves your website’s performance by reducing page load times.
Our WordPress Business hosting plans and above include a free CDN. The tool also comes with website optimization features, such as WebP image compression and CSS and JavaScript file minification. Head to Websites → Performance → CDN to check its status.
Conclusion
413 Request Entity Too Large is an error that occurs when the client sends a request larger than the web server’s file upload limit. If left unresolved, it can hurt user experience and even search engine rankings over time.
Let’s recap the five effective methods to fix this error code in WordPress:
- Reset file permissions.
- Increase the PHP upload size limit via hPanel.
- Modify the functions.php file.
- Add new rules to the .htaccess file.
- Adjust the NGINX configuration.
We hope this article can help you troubleshoot the 413 error and prevent it from happening again. If you have any questions, check out the FAQ section or drop a comment below.
413 Request Entity Too Large FAQ
This section covers some of the most common questions about the 413 Request Entity Too Large error.
What are the causes of 413 Request Entity Too Large error?
Uploading files or sending data that exceed the server’s upload size limits causes the 413 Request Entity Too Large error. Incorrect file permissions, insufficient server resources, or incorrect server configuration can also trigger this HTTP error code.
Is there a file size limit that triggers the 413 Request Entity Too Large error?
Yes, the 413 Request Entity Too Large error occurs when a file or request exceeds the server’s size limit. The maximum file upload size limit varies depending on the web host but is usually around 128 MB by default.
Do I have to reduce my file size to avoid 413 Request Entity Too Large error?
That’s not always the case, as you can raise the server’s maximum file upload size limits instead. However, reducing file size is another effective way to avoid the 413 Request Entity Too Large error.