HTTP error in WordPress when uploading images and its fix

Posted by & filed under Troubleshooting, Tutorials, WordPress, WordPress Error.

http error wordpressEvery platform have some pros and cons. Talking about cons, almost every platform gives some errors which are frustrating and annoying like database connection errors, HTTP error, white screen errors, etc. You must know how to get rid of them and know the way out of such errors and problems.

Like any other platform, WordPress also runs into HTTP errors when you try to upload image using build-in media uploader without giving any reason for that error. This error is annoying as you spent considerable time in choosing the image for your blog post and spent a lot of time in editing that image as per your blog need. Finally, after doing all these you try to upload that image to WordPress and you get a HTTP error with no cause. This is frustrating.

Sometimes, when you upload image in WordPress using the build-in media uploader, you get an HTTP image upload error. This is frustrating, as we do not get the actual cause of the error. In this article, you will come to know the possible causes of these types of errors and their solutions.

What is HTTP error during uploading images?

In WordPress, during uploading a image you may face HTTP image upload error. This error is basically the code which indicates that something went wrong during the upload and need to be fixed. This type of error occurs when you try to upload media to WordPress using built-in media uploader.

HTTP error WordPress

Unlike browser errors, where we get the error code and can reference that error code for the actual problem and its solution, WordPress errors are little difficult to solve (as we do not get the actual cause of the error).

However, WordPress can not figure out the actual cause of these errors but these errors can be fixed using the solutions in this article.

Why HTTP error occurs?

There are many reasons for these errors to occur such as too large image file, plugin causing issue, WordPress memory limitation, etc. WordPress is unable to figure out the actual cause of the error. We need to figure out the cause and then fix it.

Some causes of the error are:

1. Plugin Issue

If the HTTP error occurs after installing some new WordPress plugin, then chances are there that plugin might be causing the issue or hindering with the media upload that causes error.

2. Theme Issue

If you have switched to different theme and observed the HTTP error, then possibilities are there that theme might be causing the error.

3. WordPress Memory Limit

There are chances that your WordPress memory limit is low and hence during upload of media it runs into memory shortage and consequently, it causes the error while uploading any media.

4. Default image editor

Imagick is default image editor of WordPress and is known for consuming more memory than other image editor library. When you upload the media, it exhausts the available memory in WordPress causing the error.

5. Wrong filename

Sometimes, we unintentionally insert special character in the filename. If any special character, like colon or semi-colon, is present in the name of the file, WordPress will give the HTTP error.

How to fix the HTTP errors during image upload

As WordPress does not figure out the actual cause of the error and we need to figure it out and fix it. So we need to try hit and trial method in order to fix the error. We have already discussed some causes of this type of error and now we will see the solution of the above causes and some more causes.

Some of the solutions are:

1. Refresh the page

First and foremost thing you should do whenever you encounter HTTP error is refreshing your browser page. There are possibilities that your browser might have lost connection temporarily with WordPress and the uploading process simply failed to complete.

Sometimes, WordPress logs you out, for whatever reason, when you refresh the page you see the login page and a message “Your session has expired. Please log in to continue where you left off.” This indicates that your login session has expired and you must login again to continue.

Session Expired
2. Check your filename

Sometimes, you end up the editing of your image file by naming it including the special characters. This gives an error on uploading that file to WordPress.

Check the name of your file. It should not contain a special character like semi colon, equal sign, apostrophes, etc (dashes are OK). If it is there remove it and try re-uploading it with a new name (without special characters).

Check Filename

If error persists, then follow next solutions.

 

3. Switch the Browser

It might be possible( but possibility is less) that the error is unrelated to the website and browser is causing the issue, you may try switching the browser and re-upload the image.

This may solve the problem. If not, read on for more solutions.

4. Reduce the size of the file

The size of the file may be the reason for that error. In order to get rid of that error reduce the size of the file which you want to upload. You may decrease the width/height (pixels) of the image to reduce the size of the file. You can use the tools available offline as well as online to optimize the image for you.

There are many plugins available which can do this for you when you upload the image.

5. Make sure error is not temporary

You may get HTTP error in WordPress on uploading image or any other media sometimes because of low server resources or unusual network traffic on WordPress hosting servers. This issue is fixed automatically after the network traffic is reduced or resources needed by your website are available on WordPress hosting servers, and your website can use them. You may experience this too, resulting in HTTP error while uploading images or other media.

In this case, you should wait for few minutes so that traffic is reduced or necessary resources are available to use on hosting servers and try re-uploading the media. Also, try reducing the size of image or the format of the image and upload it. If it does not work then try other solutions.

6. Deactivate Plugin

There are some situations where some plugins like image optimization plugins (they tie directly into the media library) and security plugins like WordFence hinders the uploading of the image and thereby, giving up the HTTP error while uploading the image. Security plugins are sometimes too restrictive and hinders the uploading of the image.

If you have recently installed any plugin, and then getting the HTTP error on image upload. There might be possibility that plugin is causing the issue. You may uninstall the plugin and try re-uploading the image. This might solve the issue. If not, follow other solutions.

deactivate plugin

If you do not want to affect your live site then simply clone the site to the staging environment and then try out the solutions on the cloned site. Later, apply these changes to your live site.

7. Switch Theme

Same is the case with themes, although they do not directly tie into the media library but sometimes, themes may also cause this issue. In this case, backup your data and switch to default theme (twenty seventeen) and then try to upload image. However, changing the theme of your WordPress site will not affect your data as your data is safely stored in database. You may also stage up your live site and change the theme on your staged site to see the results without affecting your live site. Later, switch the theme on your live site as well.

twenty-seventeen theme

This might solve the problem if the HTTP error is occurring because of the theme.

8. Check uploads folder permission

When there is permission error for any folder in WordPress, it gives an appropriate message of not being able to write to the directory. But this is not always the case. If WordPress is infected with malware or hacked, there could be a lot of permission related issue. So it is better to check the folder permission before attempting other solution.

The main folder to concern about is /wp-content/uploads. This is the folder where all files are stored which are uploaded via media library.

You can use FTP client to see the permission of your uploads folder.

folder-permission

According to the WordPress Codex, all directories should be 755 (drwxr-xr-x) or 750.

9. Increase WordPress Memory Limit

One of the cause for this type of error is lack of memory available for WordPress to use to upload the image in the background. This cause is most common cause in the case of shared WordPress hosting. In order to fix it, you must increase the memory limit of WordPress so that PHP can use it on the server.

To increase the memory limit of WordPress, you need to add following code to your wp-config.php file. The wp-config.php file is present in root folder of the website.

 

This code will increase the memory limit of WordPress to 256MB, which is enough to upload the media.

10. Change WordPress Image Editor Library

WordPress uses PHP and to handle images PHP uses two modules. These modules are GD library and Imagick. WordPress uses either of them depending on the availability of the library. They both are great in their work but Imagick is known for exhausting available memory and run into memory issues causing the HTTP error because of lack of available memory.

To fix this issue, we can change the default Image Editor Library to GD library.

To do this, just add the following code to your theme’s functions.php or site-specific plugin.


 

After adding this code to the functions.php, try re-uploading the image. If it does not works, remove the code from the theme’s functions.php and try other solutions.

11. Make Changes to .htaccess file

The .htaccess file is present in the root folder of your website and it acts as the control of the website. It controls the requests to the functions. Many shared hosting providers limit Imagick to use multiple thread for faster image uploading which causes the HTTP error.

To fix this issue, you can add following code to your .htaccess file:

 

This code limits Imagick to use single thread to process the image.

Now, try re-uploading your image and check if problem is solved.

12. Check the PHP Version

WordPress requires PHP version 5.2.4 or above (since WordPress version 3.2) to run smoothly. Some hosts uses older version of PHP. If the PHP version is older then you may get this type of error.

The solution to this is ask your hosting company to upgrade your PHP version or choose a hosting company that provide you newer and stable version of PHP.

13. Disable mod_security

Mod_security is basically a open source firewall that may hinder in uploading of image and give the WordPress HTTP error. In order to disable the mod_security so that it does not hinders with the process of image uploading, you can add the following code to your .htaccess file on the top.

 

This code will disable the mod_security firewall and thereby, preventing the WordPress HTTP error to occur during the file upload.

14. Clear the Cache

Are you still getting the error? There might be possibility that you have solved the error previously while attempting previous solutions and the error which you are seeing is coming from the cached data of your browser. Clear the cache memory of the browser and try uploading the image. This may solve the issue.

15. Install Add From Server Plugin

If you have tried all of the solutions listed above and still unable to solve the problem then last but not the least solution is to install the free plugin available name Add Server Plugin.

Add from server logo

This is a temporary solution for the issue, you can add this plugin to your website till you are waiting for the response from your WordPress host or a developer on how to get the WordPress HTTP error resolved.

It can be considered as a good temporary solution if you are in the middle of some important task. It was originally developed to allow you to add very large files via SFTP.

Important: This plugin is no longer maintained or supported. Use this plugin at your own risk.

Leave a Reply