413 Request Entity Too Large error?

Did you just receive the error “413: Request Entity Too Large” on WordPress instance?

This is my brief guide to let you know what it means and how to resolve the issue.

My setup is using WordPress by Bitnami hosted on the Google Cloud Platform, but it should work on any WordPress set up that you have hosted on your own servers.

Why have you just received the error: “413: Request Entity Too Large” on WordPress?

Main reason: Your nginx web server has a limit on uploads by default, so you need to increase the default limits.

In more detail, it indicates that your web server configured to restrict large file size. Your nginx web server can be set to allow the maximum size of the client request body using client_max_body_size directive.

If the size of a request exceeds the configured value, the 413 (Request Entity Too Large) error message returned.

As these are the defaults for an ngnix server:

Source: https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size

I received this when I was recently migrating a backup of WordPress onto a new instance/ set up of WordPress. So the file sizes we were looking at were bigger than the default settings in place.

So naturally, we just need to increase these limits.

How do you manage the “413: Request Entity Too Large” error?

This is for a Nginx web server configuration, to fix this issue edit your nginx.conf.

To do so on Google Cloud Platform:

Step 1 – Login to the remote server using SSH client

Step 2 – Open the ngnix.conf file to edit using a text editor

You will want to open and edit your ngnix config file using a text editor. I am using nano editor to edit this:

$ sudo nano /etc/nginx/nginx-app.conf

You can also use vi editor or vim editor, using the word “vi” or “vim” instead of “nano”, such as the following:

$ sudo vi /etc/nginx/nginx-app.conf
$ sudo vim /etc/nginx/nginx-app.conf

If you’re using Bitnami WordPress, this file is stored at: /opt/bitnami/apps/wordpress/conf/nginx-app.conf

Type the following command to edit your nginx.conf using a text editor:

You’re looking for the client_max_body_size parameter of the ngnix configuration (more information at https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size). By default, that’s set to 1MB so, in order to change that, edit your configuration file.

$ sudo nano /opt/bitnami/apps/wordpress/conf/nginx-app.conf

Add the following line to http or server or location context to increase the size limit in nginx.conf, enter:

$ client_max_body_size 8M;
Example of adding this to the top of your nginx-app.conf using nano editor

Then press: Control + O to “Write Out” (save the changes), which will tell the server to save the settings.

Step 3- Reload the nginx webserver

Restart your ngnix web server:

$ sudo /opt/bitnami/ctlscript.sh restart nginx
 (if needed) $ sudo /opt/bitnami/ctlscript.sh start nginx
Example commands in the SSH command line

You should receive and see something like this:

 Unmonitored nginx
/opt/bitnami/nginx/scripts/ctl.sh : Nginx stopped
/opt/bitnami/nginx/scripts/ctl.sh : Nginx started
Monitored nginx

Then you can confirm that your ngnix web server is back up and running here with:

$ sudo /opt/bitnami/ctlscript.sh status
Nginx already running
php-fpm already running
mysql already running

STEP 4- Upload the file again

Try uploading the file again that gave you the “413: request entity too large” error. You should no longer see the error messaeg.

Hopefully that helps you to get this working this time round!

Images loading from IP address on WordPress

If you’re like me, you may be surprised to suddenly find that images on some of your posts have an image loading from an IP address instead of your domain name on your WordPress website.

Images loading from IP address instead of domain name on WordPress

I did not realise I had some broken images and maybe even images loading off my WordPress IP address instead of www.dejavuguides.com which is you’d want your visitors to see. (You can read more here if you’re interested in why exposing your origin IP address is not a good idea – Cloudflare hides your origin server IP addresses for traffic you proxy to Cloudflare).

Example of images not loading

Here is an example of one of my images that was not loading.

Images not loaded, why?

Discovered images loaded from IP address instead of domain name on WordPress

I looked into the HTML code and discovered one of my WordPress IP addresses was being referenced for the image.

Most likely as I had writing new blog posts via my WordPress IP address at https://35.230.x.x/wp-admin directly instead of https://dejavuguides.com/wp-admin so it automatically picked up that IP address to reference to.

IP address listed where I am storing my image!

So I can manually update these links so it says https://www.dejavuguides.com/wp-content/….

That allows the image to load now which you’ll see below. (You can also test this via the following and you’ll see that only my newly updated link works).

  • https://www.dejavuguides.com/wp-content/uploads/2019/02/google-service-center-hours-1024×768.jpg vs
Image loaded after updating link

Great news is this fixed my images and made sure that they are loading. Now the question is how do I know and check if this is an issue for my other posts? How do I do that at scale?

Well, we can WordPress plugins to help us 😉

So we can use a WordPress Plugin that does a search and replace like functionality. You can use any that you prefer, but the goal now is to search for your WordPress IP address and do a very specific update to any references to this old WordPress IP address. Always back up your database before making changes here.

I personally like to use these WordPress plugins:

Once you have selected one of these you will want to use them in “dry run” mode, so you can review before any action is taken.

  • Case-insensitive = Yes
  • Replace GUIDs = Leave unchecked
  • Run as dry run? = Yes

Example of fixing this image IP address on WordPress using “Better Search Replace” plugin

Example of images loading properly now after the fix

Example of using “Velvet Blues Update URLs” plugin to Images loading from IP address on WordPress

If you want to use the Velvet Blues Update URLs to change the IP address to your current domain name. I recommend using the “URLs in page content” box. But can also consider the other options as well. Just make sure that you do back up and update your website when you can.

Updating URL links using Velvet Blues Update URLs plugin

Please feel free to comment below you have questions or tips for other readers to resolve this problem as well. Happy blogging!