How to Fix HTTP Errors Uploading Images

Posted on Apr 8, 2019


One of the most annoying things that can happen to your WordPress site is an HTTP error when trying to upload images – there are many ways to deal with this issue.

CHECK IF THE ERROR REALLY EXISTS

Basically, just wait for a few minutes and then check if the error comes up again, because the error may only be temporary.

TRY USING ANOTHER BROWSER

If the error still comes up, the second easiest option is just to switch between browsers. Google Chrome can often disable image uploading, so just try Firefox, Opera, etc.

DEACTIVATE PLUGINS

HTTP errors like this one could happen right after installing a plugin, particularly if it’s for image optimization. Try even disabling other plugins before trying to upload your picture once more.

INCREASE THE MEMORY LIMIT

Problems in WordPress can be easily caused by memory limits – this can be easily fixed by adding the following code to wp-config.php:

define (‘WP_MEMORY_LIMIT’, ‘256M’);

By using this solution you will be solving your image upload problem and then some along the way, especially if your theme uses a lot of resources.

SWITCH BETWEEN IMAGE EDITORS

WordPress uses two image editors interchangeably: Imagick and GD Library. Imagick has the tendency to drain memory and henceforth cause HTTP errors. Just add the following code to your theme’s functions.php file:

function wpb_image_editor_default_to_gd( $editors ) {
$gd_editor = ‘WP_Image_Editor_GD’;
$editors = array_diff( $editors, array( $gd_editor ) );
array_unshift( $editors, $gd_editor );
return $editors;
}
add_filter( ‘wp_image_editors’, ‘wpb_image_editor_default_to_gd’ );

USE .HTACCESS

If you still want to use Imagick you can use another trick to prevent HTTP errors, which is to add this line of code to .htaccess:

SetEnv MAGICK_THREAD_LIMIT 1

CHECK YOUR THEME

Much like plugins, WordPress themes can also cause this HTTP error. Just try a different theme and see if the error still comes up.

UPGRADE PHP VERSION

If your hosting service is using an older PHP version, you’ll likely end up running into HTTP errors like this one and then some. If you can’t upgrade the PHP version from your control panel, you should either choose a more advanced service or change your provider entirely.