Images loading from IP address on Wordpress

May 1, 2020 5:27:00 PM / by Vu Long Tran

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-1024x768.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!

Topics: web development, blogging, wordpress

Vu Long Tran

Written by Vu Long Tran

Solutions Engineer APAC. ex-@Forrester consultant. Writing on #cloud #howto guides and #tech tinkering!