Support » Fixing WordPress » HTTP Error when uploading images (but not all failing!)

  • Hi, I had issue with uploading photos after 3.5.1 upgrade. I had aprox 100 files on my PC, already resized to 900x600px. I wanted to create Gallery in a post, and every time (I tried manytimes) some of them failed to upload with “HTTP Error”. Different images everytime, not the same ones.

    It failed on /wp-admin/async-upload.php script, which was unable to return anything in 60 seconds and webserver returned error 504 Gateway timeout (as I saw in “Network” activity) – it appeared as a red HTTP error in Media window. An original image was uploaded, but there were no thumbnails. What? Webserver needs more than 60 second to resize image from 900px to 150px???

    I have googled countless times … there are no memory issues, no not-writeable upload dir, no mod_security on etc. Some images are proccesed, some aren’t.

    And solution? Imagick PHP library. Script freezes on line “$this->image = new Imagick( $this->file );” in wp-includes/class-wp-image-editor-imagick.php. My webhost has ImageMagick 6.6.8-5 2011-05-03 Q16 version, quite obsolete. Now I am waiting for an upgrade. PHP version is 5.3.6.

    I have forced WP to choose “old” GD library for dealing with images and for the first time I have uploaded all 107 images at once without any error.

    So, I believe irregular HTTP errors when uploading photos can be related to ImageMagick library.

Viewing 15 replies - 1 through 15 (of 18 total)
  • Gwythan


    How fast is your upload speed on your Internet connection? PHP is set to timeout after about 30 seconds. It could be that your large files are taking too long to up load.

    To find out what the timeout value for PHP is, install the PHP Server Info plugin and look for the max_execution_time setting

    Thread Starter mklusak


    Nope, upload speed is not an issue. As I wrote before: An original image was uploaded, but there were no thumbnails.

    I am PHP programmer and I have dealt with “common” upload problems on many sites and webhosts. This behavior was something new for me.

    As I can say, I have found the solution, or “the main thing causing the problem” (ImageMagick lib.) and I wrote this post mainly to make my findings searchable.

    At first, I wanted to thank you a lot. You really saved my day, I was struggling with exactly same problem for few days now.

    Also same fix worked for me (disabling IM within WP). How did you disable it and forced WP to use GD? Is there maybe some constant to add in wp-config to do that? Since it’s quite new feature, I haven’t found much in documentation. I rewrote the IM availability in class-wp-image-editor-imagick, so it would always result in false, but this is not really clean solution and it will work till next update…

    If your host will update the library and you will test it again, please let us know, if it worked. I also need something to persuade my host to update those libraries.

    Thread Starter mklusak


    Hi, I’m glad it’s useful. I knew I couldn’t be the only one who is experiencing this issue 🙂 Well, there is a simple method using add_filter() function, so you can add this code to your theme’s functions.php file:

    add_filter( 'wp_image_editors', 'change_graphic_lib' );
    function change_graphic_lib($array) {
      return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );

    It changes order of checking for available graphic libraries, so GD is checked first and if it is present, it is used.

    It didn’t work for me…

    Thank you so much, edited the functions.php file and it solved the problem for me 🙂

    I spent 2 weeks on this problem. Switching to GD library solved.
    Thank you so much mklusak!

    Further details:

    I had multiple wp installations (all 3.5.1) on several subdirectories of the same domain and THIS EXACT THING (all mklusak details match perfectly) was happening just on one single installation.

    I noticed that deactivating some plugins this was solving as well, but I could not find the single plugin causing it, it looks like it was happening with a group of plugins:
    – Disqus Comment System
    – EG-Attachments
    – Elegant Builder
    – GetSocial

    I have 20 active plugins in that wp installation, the problem was solving only if I deactivate all 4 of them (leaving on the others 16)

    I’m using the Lucid theme by Elegant Themes V. 2.0

    Thanks mklusak, switching to GD library works for me 🙂

    mklusak thank you SO much. I registered on the forum just to be able to express my gratitude! I couldn’t find any other resources on the web and it was driving me crazy. But that code worked like a charm.



    I have had a lot of trouble with this as well. I tried switching to the GD library but that didn’t work.

    What does work is to keep scaling down the image dimensions until it succeeds. It’s not the file size or permissions. It’s the height times width dimensions.

    For instance, a height in pixels of 2400 for a particular image will never work. But a height of 2350 will always work. An image of greater width would require less height to succeed.

    When it fails, the image has uploaded but failed to “crunch”. That is, none of the smaller versions were created. Could be a limitation of the working buffer size in the graphics library. Maybe somewhere around 3.5M pixels.

    Thread Starter mklusak


    jabdulla: Well, I registered here just to have a possibility to let know about my findings 🙂 Anyway, you’re welcome!

    mlkary: I think your problem is ONLY in image dimensions, and not failing Imagick library. Problem described above was not affected by image dimensions, I have tried many of them. You are just dealing with too big images and too low RAM memory limit your script can allocate (PHP directive “memory_limit”).

    You’re a fricken legend mklusak, cheers



    Just wanted to comment and thank you mklusak for your fix.
    I believe a lot of people will be looking for this answer.

    Hello mklusak,

    I logged in ..just to say Thank You to you 🙂
    My website:

    My installation was working fine until today. This problem occurred without noticeable reason (no updates, no plugins, no nothing…) and “mklusak” solution was the only one that actually worked for me!

    Thank you mklusak!

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘HTTP Error when uploading images (but not all failing!)’ is closed to new replies.