When you encounter the Nginx error “413 Request Entity Too Large” when trying to upload a 4MB XML file via the import feature in WordPress, it usually means that the request body size is limited in the Nginx configuration. Although you have mentioned that you have set a high limit in your Nginx configuration, let’s double-check and make sure all relevant configurations are correct.
Check Nginx Configuration
client_max_body_size:
You have set client_max_body_size 1024m; in the http block, which should theoretically allow up to 1GB files to be uploaded.
Make sure this setting is not overridden by other configuration files (such as site-specific configuration in sites-available). Nginx may contain specific configurations in different files that override the global settings.
Check other configuration files:
Check the configuration files in the /etc/nginx/sites-available/ and /etc/nginx/conf.d/ directories to confirm whether there are client_max_body_size settings for specific sites or paths.
If so, make sure these settings also allow large enough file uploads.
Reload Nginx configuration:
After modifying the configuration, make sure to reload Nginx to apply the changes:
sudo nginx -s reload
Other possible reasons
Reverse proxy settings:
If you have reverse proxies behind your Nginx (such as load balancers or other Nginx instances), make sure these proxies also have appropriate client_max_body_size set.
WordPress or plugin limitations:
Although less common, some WordPress plugins or themes may limit the size of uploaded files. Check if there are related settings that can be adjusted.
PHP Configuration:
Although this error is thrown by Nginx, make sure PHP’s upload_max_filesize and post_max_size are also set large enough to avoid other possible upload issues in the future.
Browser or Network Issue:
Make sure no network devices (such as firewalls or routers) are blocking large file uploads.
Debugging Steps
Check Nginx Error Log:
Check Nginx’s error log (usually in /var/log/nginx/error.log) to see if there are more details about the 413 error.
Test Configuration File:
Use the nginx -t command to test the syntax of the Nginx configuration file to ensure there are no errors.