HTTP Error Fix when Uploading an Image with WordPress

,
How to Fix WordPress Image Upload HTTP Error

From time to time you may get an “HTTP error.” message when attempting to upload a photo to your WordPress website. This usually occurs when you are using the default WordPress built-in media uploader.

 

 

In this article, we will provide you with some potential solutions to this common HTTP error so that you can resume uploading media to your WordPress website.

 

Why did I get an HTTP error?

There many possibilities that could lead to a HTTP error notification when trying to upload media files to your website. The main reason being, WordPress is not able to determine the cause of the image upload failure. Thus it simply generates and displays a very unhelpful and generic message: “HTTP error.

Since WordPress is unable to determine the exact cause of the failure, this means we have to try a few different solutions to remedy the issue.

Here are a few potential solutions, starting with the simplest possible fixes.

 

  • Make sure the issue isn’t temporary

When in doubt, give it a few minutes and try again. This error may sometimes be caused by temporarily low server resources, which generally resolve themselves in a few minutes.

If that fails, try uploading a completely different image. If the other image file uploads, try renaming the failed upload and retry uploading. Sometimes the image is trying to overwrite an existing file that, for some reason, cannot be overwritten. It is also recommended to clear your internet browser’s cache.

If all these steps result in the same HTTP error message, this means that the error is not a temporary glitch.

 

  • Increase your servers’ PHP memory limit

The most common cause of HTTP error messages is a lack of server memory available to your WordPress installation. To fix, you need to increase the amount of memory PHP can use on your server. Do this by adding the following code to your wp-config.php file which will increase the limit to 256 Megabytes.

 

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

 

  • Change your default WordPress image editor

WordPress uses two PHP modules to handle images. These modules are GD Library and Imagick.

Imagick is known to experience issues with memory utilization. Switching over to the GD Library as your default image editor may resolve this for you. To do so simply add the following code to your theme or child theme’s functions.php file. Don’t have a child theme? We can help you setup a child theme for your WordPress website.

 

add_filter( 'wp_image_editors', 'endurtech_image_editor_gd' );
function endurtech_image_editor_gd( $editors )

{
    $gd_editor = 'WP_Image_Editor_GD';
    $editors = array_diff( $editors, array( $gd_editor ) );
    array_unshift( $editors, $gd_editor );
    return $editors;
}

 

After adding this code, clear your browser’s cache and try uploading your image again.

 

  • Using .htaccess

You may be seeing the HTTP error message if your website resides on a shared hosting environment, as many limit Imagick’s ability to use multiple threads for faster image processing.

To control how Imagick uses server resources add the following code to your websites’ .htaccess file. This will limit Imagick to a single thread hopefully resolving your image upload issue.

 

SetEnv MAGICK_THREAD_LIMIT 1

 

WordPress Website Support

We hope one of the methods described above has helped you resolve your HTTP error on your WordPress website.

If you still need help, let us resolve it for you. Simply submit a support request using the form below. Simply select “WordPress Support MidLevel” from the drop down list and we’ll be sure to get with you to help resolve your image uploading issue(s).

SUPPORT REQUEST FORM

 

If this article has helped you resolve your WordPress HTTP Error issue please like us on Facebook, share this on your social media or buy us a cup of coffee.