Last updated on June 9th, 2022 at 11:16 am

Recently I was trying to migrate WordPress posts from an old website (Running on Apache) to a new one (Running on Nginx). The error thrown on the browser was “Nginx 413 Request Entity Too Large” . I thought Instead of moving/copy pasting the data itself WordPress provides us with a one click simple solution to Import/Export posts. As you are aware this option is available under WordPress Admin Page> Tools > Import / Export.

Error I was seeing on my nginx logs were similar to the one below

2021/12/30 21:14:29 [error] 89449#89449: *204 client intended to send too large body: 2372404 bytes, client: xx.xx.xx.xx, server: mistonline.in, request: "POST wp-admin/admin.php?import=wordpress&step=1&_wpnonce=550798a3b4 HTTP/1.1", host: "mistonline.in", referrer: "wp-admin/import.php?import=wordpress"

In this case my configuration was nginx/1.18.0 (Running on Ubuntu)

The Import file will be in xml format (It is also known as WordPress eXtended RSS or WXR. It contains your posts, pages, comments, custom fields, categories, and tags.) and it was easy to import. But hit the issue while trying to export it to my new site.

How to Fix the issue ?

Step 1] We need to modify the configuration file for nginx and update the value for client_max_body_size directive.

The default value is 1M. It is normally located under /etc/nginx/nginx.conf

Step 2] Before updating the config file (/etc/nginx/nginx.conf ) make sure to take a backup using CP command. (Assuming you are running on linux flavor)

Step 3] Modify the value to say 45 MB. Again keep in mind that maximum size of the wxr file should be 50 MB so keep the client_max_body_size value lower than 50 MB.

Step 4] Save the nginx config file and run nginx -t to make sure that syntax is correct.

Step 5] Restart nginx. (systemctl restart nginx or relevant commands according to the flavor)

Step 6] Retry the import and it should work. If it is still not working and started throwing a different error check PHP upload_max_filesize and other settings especially related to file uploads/timeouts are good.

Leave a Reply

Your email address will not be published. Required fields are marked *