413 Request Entity Too Large

Hi,

I’m trying to upload a 4 mb xml file via the import feature of wordpress
When I do, i’m getting an Nginx error message : 413 Request Entity Too Large

I verified my php and Nginx conf and it has way higher limits than 4 mb

http {
	# Main settings
	sendfile                        on;
	tcp_nopush                      on;
	tcp_nodelay                     on;
	client_header_timeout           180s;
	client_body_timeout             180s;
	client_header_buffer_size       2k;
	client_body_buffer_size         256k;
	client_max_body_size            1024m;
	large_client_header_buffers     4 8k;
	send_timeout                    60s;
	keepalive_timeout               30s;
	keepalive_requests              1000;
	reset_timedout_connection       on;
	server_tokens                   off;
	server_name_in_redirect         off;
	server_names_hash_max_size      512;
	server_names_hash_bucket_size   512;
	charset                         utf-8;

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

  1. 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.

  1. 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.
  1. Reload Nginx configuration:
  • After modifying the configuration, make sure to reload Nginx to apply the changes:
sudo nginx -s reload

Other possible reasons

  1. 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.
  1. 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.
  1. 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.
  1. 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.