8 Reasons for HTTP error while uploading Image in WordPress

Updated on October 19, 2017

Are you getting HTTP error while uploading image in WordPress? The good news is, you are not alone. Recently, one of my client had a problem in uploading image in WordPress and here’s what I learnt while fixing the issue. Generally, this error occurs while uploading an image and in most cases, the error appears even if the image was uploaded to the media folder or no thumbnails being generated.

Sometimes the error might occur only for a particular image. So you might have to try uploading a different image to see if the problem occurs again. However, there are plenty of reason for HTTP error and here are few.

HTTP Error while uploading Image in WordPress

Due to bigger image size

Probably, you are uploading an image with very high resolution. For example, my client was uploading an image of size 4254px x 1483px and its size on disk was 3.22MB. Though WordPress upload page supports image size of 64MB (this might differ on your WordPress installation), it still ended up in throwing HTTP error.

Fix: To fix this error, I had to decrease the image size to less than 1200px. Some users in WordPress forum suggests, if the width of your post content is 700px, then you should not upload an image larger than that (well, this suggestion is not entirely true, because I have been uploading bigger images for while in this site).

Due to Plugin conflict

If you had installed a plugin recently, then try disabling/deactivate it and upload the image again. Sometimes, the plugin might conflict with an image upload and trigger HTTP error.

Disable Image optimizer plugins

Are you using any image optimizer plugin, such as EWWW image optimizer then try disabling it and upload the image again. For example, I had installed EWWW image optimizer plugin on my client website. After seeing HTTP error in the image upload page, I navigated to Media page to see if the image has uploaded or not. The image was uploaded successfully, but the Image Optimizer column said “Not processed“.

wordpress image optimizer

Fix: Sometimes, the optimizer plugins may not be able to process the uploaded image.  Hence, I deactivated the plugin and uploaded the image successfully.

Note:

But image optimizer plugins are important to improve your site’s load time. You should activate the plugin after uploading the problematic image.

Due to PHP Memory limit

The error might be due to the memory limit in PHP. Try adding the below line in wp-config.php file and upload the image again.

define( 'WP_MEMORY_LIMIT', '256M' );

If your hosting does not allow to increase PHP memory limit, then you may need to contact them to fix the issue.

You may also increase memory limit by adding the below line in .htaccess (for those who don’t have access to php.ini)

php_value memory_limit 256M
Note:

If your server or hosting does not have enough memory, then you will end up in seeing “500 Internal Server error”. In such cases, this solution is not for you.

If you have an access to php.ini in your web server, then change the value of ‘memory_limit‘ as shown below.

$ vim /etc/php.ini

memory_limit = 256M

Due to Mod_security

Try to turn off “SecFilterEngine” and “SecFilterScanPOST” in mod_security. To do that, add the below lines in .htaccess located in wp-admin directory.

<IfModule mod_security.c>
 SecFilterEngine Off
 SecFilterScanPOST Off
 </IfModule>

500 Internal server error – async-upload.php

Check if you see an error in JavaScript console while you see HTTP error. For example, you will see an error as shown in the below screenshot.

The 500 internal server means, something is wrong in the server, but the server couldn’t find an exact reason for the problem.

Try excluding async-upload.php (file upload script) from server authentication by adding the below code in .htaccess file located in wp-admin directory.

<FilesMatch "(async-upload\.php)$">
 Satisfy Any
 Order allow,deny
 Allow from all
 Deny from none
 </FilesMatch>

Image filename has an apostrophe

Make sure that the image you are uploading does not have a filename containing apostrophe. Few users have faced HTTP error when the filename contained apostrophe.

Issue with Image Manipulation library

Try changing the image manipulation library by adding the below code in 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' );
}

If the image is uploaded successfully, then you should also see thumbnail being generated properly.

Finally, the HTTP error can occur due to any of the above said reasons. So it’s better to try out only one solution at a time and see if that works for you before moving on to the next option.

Have you faced this error? Let’s know how you fixed it in the comment section below.

Was this article helpful?

Related Articles

Comments Leave a Comment

Leave a Comment