Introduction

Encountering the “413 Request Entity Too Large” error in WordPress can be frustrating, especially when you’re trying to upload a large file or install a new theme or plugin. This error occurs when the server is configured with a limit on the size of files that can be uploaded, and your file exceeds this limit. Fortunately, there are several ways to resolve this issue.

Fixing “413 Request Entity Too Large” Errors

For Apache Servers

A) Modify the .htaccess File

  1. Access your website’s root directory via FTP or your hosting control panel’s file manager.
  1. Locate and edit the .htaccess file.
  1. Add the following lines to increase the upload limit:
  • php_value upload_max_filesize 64M
  • php_value post_max_size 64M
  • php_value max_execution_time 30
  • php_value max_input_time 300
  1. Save and upload the .htaccess file back to your server.

B) Update the php.ini File

  1. Access your website’s root directory via FTP or your hosting control panel.
  1. Locate or create a php.ini file.
  1. Add or update the following settings
  • upload_max_filesize = 64M 
  • post_max_size = 64M 
  • max_execution_time = 300
  1. Save and upload the php.ini file to your server.

For Nginx Servers

A) Modify the Nginx Configuration

  1. Access your server’s Nginx configuration file, typically located at /etc/nginx/nginx.conf or /etc/nginx/conf.d/.
  1. Add or update the following directive within the http, server, or location block:

    client_max_body_size 64M;
  1. Save the file and restart Nginx to apply the changes:

    sudo systemctl restart nginx

By Editing Your Functions.PHP File

You can also boost the maximum file upload size in WordPress by modifying the `functions.php` file of your active theme. Keep in mind that this adjustment will revert to the default settings if you change themes, so it’s a good idea to back up your file before making any changes.

Here’s how to change the maximum file upload size by modifying functions.php file:
From your WordPress dashboard, navigate to Appearance -> Theme Editor



Open the theme functions file ‘functions.php’ and add the following code one by one to the file. Once you are done, save it.

  • @ini_set( ‘upload_max_size’ , ’74M’ );
  • @ini_set( ‘post_max_size’, ’74M’);
  • @ini_set( ‘max_execution_time’, ‘400’ );


By following these steps, you can adjust the file upload size limit on your web server and prevent the “413 Request Entity Too Large” error. Whether you are using Apache, Nginx, or IIS, you can configure your server to allow larger file uploads, ensuring smoother operation of your website.



Conclusion

By following these steps, you can adjust the file upload size limit on your web server and prevent the “413 Request Entity Too Large” error. Whether you are using Apache, Nginx, or IIS, you can configure your server to allow larger file uploads, ensuring smoother operation of your website.