“Failed to import Media” when importing WordPress blogs

A few days ago I installed a local instance of WordPress under Windows, to experiment with importing my https://grenville.wordpress.com site. This post documents a small problem and solution with some of my current blog’s images being identified using https:// instead of http:// URLs.

After confirming the Windows WordPress installation was up and running (with an essentially empty blog), I created an export of https://grenville.wordpress.com into a local xml file, thinkingtoomuch.wordpress.2012-09-04.xml

Importing this xml file into my Windows WordPress installation, with “download attachments” checked, did a reasonably good job of recreating my blog on the local machine. All posts, pages and comments re-appeared, and a vast majority of my images were pulled over as well.

Unfortunately, a sizable number of images were not retrieved. My local instance of WordPress complained multiple times with the same error message: “Failed to import Media ….”

Some online searching threw up the following informative blog post:


The hint (which turned out to be accurate) is that some of my current blog’s images are referred to using https:// rather than http:// URLs. While doing the importation process, my local WordPress was barfing at being presented with a site certificate when attempting to retrieve https://grenville.files.wordpress.com content, and so each affected image was simply failing to import.

The partial solution was to run through the .xml file and convert each instance of https://grenville.files.wordpress.com to https://grenville.files.wordpress.com — the resulting xml file could then be successfully used to ‘import’ my current blog site into the locally hosted instance of WordPress. From my FreeBSD command line:

cat thinkingtoomuch.wordpress.2012-09-04.xml | sed 's+https://grenville.files+http://grenville.files+' > revised.xml

does the trick (with revised.xml being the file you now use to import the blog)

Unfortunately, although my images are now all imported, scaling information appears to have been lost during importation (so my Posts have galleries where the thumbnail previews are all the wrong sizes). Figuring out why is still on my TODO list….



  1. i have the same problem, i have xml about 6MB, and when uploading i am getting error!

  2. Awesome!!!! This did the trick for me too … just change https to http BUT ONLY for the files url

  3. Just what I needed! That crazy “s” was the issue. This is why blogs should never go offline – a 3 year old post just saved me hours of hair-pulling!

  4. Thank you for the suggestion, it worked. It was the issue with the “https://” as you pointed out.

    I did the following find and replace:

    Find: “https://” -> Replace: “http://”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: