How to fix the WordPress HTTP error (uploading the image to the media library)


As with any platform, there are always those errors or annoying problems that you have to learn how to work. Trust us, we've seen them all practically! From the white screen of death to database connection errors, WordPress certainly has its whims. 😉 But we still love it! Today we will immerse ourselves in one of the most common, the HTTP error. Users typically encounter this when they try to upload images or videos to the WordPress media library.

While HTTP error is usually easy to solve, it can be quite frustrating as it usually interrupts the workflow. Nothing is worse than spending 20 minutes trying to find that perfect picture for your blog post, go to upload it, and bam, all of a sudden you came across a very vague mistake.

Below we'll look at why this error occurs and what you can do to fix it quickly so you can get back to loading your media files.

What is the WordPress HTTP error?

The HTTP error of WordPress occurs when something goes wrong while trying to upload images or videos using the built-in media library tool. Unfortunately, unlike browser errors where we can usually refer to an HTTP status code, WordPress errors are sometimes a bit more difficult to solve (especially if you do not know how to enable debugging).

The vague "HTTP error" certainly does not help you determine what could be wrong or even where to start looking. But that's because there could be some causes for the error and WordPress simply does not know why, so it spits out a generic error message (as seen below).

How to fix the WordPress HTTP error (uploading the image to the media library)

HTTP WordPress error when loading images

How to fix the HTTP WordPress error

From our experience, WordPress HTTP error generally comes from two factors: the first is a client-side or user-side error (your login session, incorrect characters in the file name, etc.), and the second is a problem or setting on your WordPress host (server problem, memory list, third-party plug-in, shared hosting restriction resources, etc.). So we will dive into a bit of both.

Here are some tips and things to check to correct the error (sorted by the most common reasons we see):

  1. Reload the page
  2. Reduce or resize the file
  3. Rename the image file
  4. Temporarily disable plugins and themes
  5. Ask your WordPress host
  6. Increase the PHP memory limit
  7. Check the permissions of the upload folders
  8. Switch to the latest version of PHP
  9. Resolve performance issues with Imagick and Shared Hosts
  10. Remove custom media library path
  11. Disable mod_security
  12. Install the Add to server plug-in

1. Refresh the page

The first thing you should do when you encounter WordPress HTTP error is simply refreshing the page in your browser. It seems too easy, right? 😉 Well, actually this is the most common correction we've seen for this. Here because:

First of all, for any reason, your browser he may have lost the connection temporarily with WordPress and the process simply has not been completed. This could be due to your ISP, a temporary hiccup with your WordPress host, etc. If you update the page and try to load it again, the error sometimes resolves itself.

Secondly, we have also seen that sometimes after updating the page that WordPress has suddenly thrown out. This is an indicator of your WordPress the login session has expired. Normally WordPress will throw you off immediately, but if you're in the middle of uploading the media it may not do it. After logging in, you can try to upload the media file again.

2. Reduce or resize the file

It may be necessary to edit the image file, which may result reducing the file size (KB or MB) o decreasing the width / height (Pixels). We advise you to consult our in-depth post on how to optimize images for the web. There are many third-party image enhancement plug-ins that you can use to automatically perform this task for you (reduction and resizing) when the image is loaded into the media library.

We have used Imagify on our Kinsta website for years without a single problem. But there are many other great ones out there. Just be sure of the plug-in you use, which are optimizing images on their servers, not locally. If you perform collective optimization of images locally, this can dramatically damage the performance of your site.

How to fix the WordPress HTTP error (uploading the image to the media library)

Imagine the WordPress plugin

It is good to upload high resolution images like WordPress supports reactive images out of the box. In fact, you'll probably want the image to appear crisp on the retina displays. However, unless you are a photographer or a company that needs high resolution images, a good general rule is to keep the final image size under 100 KB and not more than twice the width the width of the content of your website.

Also, you may have to play with PNG and JPG file types. Sometimes one can be much bigger than the other depending on the type of image it is.

Depending on your WordPress host configuration, you may also want to increase the size of the WordPress maximum upload file.

3. Rename the image file

It can never hurt to try and rename the image file. WordPress should automatically add a number at the end if you try to load a duplicate file name, but in case it does not work, try renaming the file. Unfortunately, WordPress does not allow you to rename the file of an already uploaded image file, so you'll have to rename it locally and reload it.

When we load existing images, we usually add a -1 or -2 at the end (example: image-file-1.png, image-file-2.png). Be sure to add the hyphen, otherwise Google will read it as a word and may damage your SEO.

Also, to be sure, avoid uploading an image with file names that contain special characters. This includes international language symbols and characters such as apostrophes. The dashes are fine. You can see in this example below on the Japanese Kinsta website, we are using English for file names, not for special characters. While WordPress can support them technically, there are many other problems that may appear.

How to fix the WordPress HTTP error (uploading the image to the media library)

Rename the image file without special characters

4. Temporarily disable plug-ins and themes

It's always a good idea if you have HTTP errors to try deactivating your plugins and even pass the WordPress theme to the default value to see if this solves the problem. Some plugins that are typical culprits include image optimization plug-ins (which link directly to the media library) and security plugins such as WordFence (these plugins are sometimes too restrictive).

If you do not want to influence your live site, simply clone your live site in a staging environment. If the WordPress HTTP error also occurs during staging, you can quickly disable all your plugins to start narrowing down.

Remember that you will not lose any data if you simply disable a plugin. If you still manage to log in to the administrator, a quick way to do this is to select "Plugin" and select "Disable" from the collective actions menu. This will disable all your plugins.

How to fix the WordPress HTTP error (uploading the image to the media library)

Turn off all plugins

If this solves the problem, you will have to find the culprit. Start activating them one by one and try uploading an image to the media library again. When you see the HTTP error return, you have found the wrong plug-in. You can then contact the plugin developer to ask for help or publish a support ticket in the WordPress repository.

If you can not log in to your administrator, you can FTP to your server and rename your plug-in folder to something like this plugins_old. Then check your site again. If it works, you will have to test each plugin one by one. Rename your plugin folder plugins and then rename each plugin folder inside if, one at a time, until you find it. You could also try replicating this on a staging site first.

How to fix the WordPress HTTP error (uploading the image to the media library)

Rename plugin folder

The same applies to your WordPress theme. Generally the themes are not related to the multimedia library, but we have seen some strange settings. It never hurts to try to pass the theme to the default Twenty Seventeen theme to see if it solves it. Just like with plugins, you do not have to worry about losing your current theme settings. All of this is stored in the database.

5. Ask your WordPress host

If you've already tried the above steps and are still getting the WordPress HTTP error, we recommend reaching your WordPress host for assistance before proceeding. Many of the additional troubleshooting steps are a bit more advanced and many times you can ask your host to do it or check it for you.

The Kinsta support team is available 24 × 7 from the lower right side of the MyKinsta dashboard.

How to fix the WordPress HTTP error (uploading the image to the media library)

Kinsta WordPress hosting support

6. Increase the PHP memory limit

Another cause of WordPress HTTP error is yours the server is missing the available memory for completing the background upload process. This is a very common problem with shared WordPress hosting. To solve it you need to increase the amount of memory that PHP can use. 256 MB is recommended.

The default memory limit for Kinsta clients is already set to 256 MB. If you host your WordPress site on Kinsta you should not have problems with the lack of memory. 👍

Increase the PHP memory limit with wp-config.php

You can increase the PHP memory limit by adding the following code to yours wp-config.php file. Note: This can be overridden by a server-level rule in place by your WordPress host.

define (& # 39; WP_MEMORY_LIMIT & # 39 ;, & # 39; 256M & # 39;);

Increase the PHP memory limit in cPanel

If the host uses cPanel, it is possible to increase the PHP memory limit in two different areas.

The first is under the software section. Click "Select PHP Version". Click "Switch to PHP options". You can then click on "memory_limit" to change its value.

The second area is also under the software section. Click on the "MultiPHP INI Editor" tool. This allows you to change the php.ini file. Just scroll down where it says "memory_limit" and enter a higher value.

How to fix the WordPress HTTP error (uploading the image to the media library)

Increase the PHP memory limit in cPanel

Increase the PHP memory limit with php.ini

If you do not use cPanel, you can also edit the file php.ini file directly if you have access. To do so, access your site via FTP or SSH, go to the root directory of your site and open or create a php.ini file.

If the file was already there, look for the "memory_limit" setting and edit it if necessary.

Some shared hosts may also request to add the suPHP directive to yours .htaccess files for the above php.ini file settings to work. To do this, edit yours .htaccess file, which is also located at the root of your site, and add the following code to the top of the file:

suPHP_ConfigPath / home / yourusername / public_html

Increase the PHP memory limit with .htaccess

The .htaccess file is a special hidden file that contains various settings that you can use to change the behavior of the server, up to a specific level of the directory. If you do not have access to php.ini, we suggest you try this later. First, log in to your site via FTP or SSH, check the root directory and see if there's a .htaccess file there.

If there is, you can edit that file and change the value "php_value memory_limit".

7. Check the permissions of the upload folders

Generally, when a folder authorization error occurs, WordPress should display a message that can not be written to the directory. However, this may not always be the case. If a WordPress site has been hacked or infected by malware, there may be many problems with permissions.

Tired of WordPress hosting support that seems to know less than what you do?

We understand! That's why Kinsta employs only highly skilled developers and Linux engineers. The experience of our support department is second to none and we are available 24 hours a day to help you!

Tip: Kinsta offers free hacking solutions for all customers. 😄

The main folder that interests you is yours / Wp-content / uploads folder, because files are stored here when uploaded via the media library.

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

You can easily see the permissions of your folder with an FTP client (as shown below). You may also contact your WordPress host support team and ask them to quickly get GREP file permissions on folders and files to ensure they are set up correctly.

Make sure that if you manually update the permissions on this folder, check both the "Recurse into subdirectories" and "Apply to onlyories" options.

How to fix the WordPress HTTP error (uploading the image to the media library)

WordPress uploads directory permissions

8. Switch to the latest version of PHP

WordPress officially recommends PHP 7.2 or higher. If you're not, you're below the minimum requirements set by CMS developers. 😮

We always recommend that you run the most recent and supported versions of PHP due to the fact that it offers better security and performance, including bug fixes and features that need to be deprecated.

We have seen earlier versions of PHP contributing to all kinds of errors, including the infamous WordPress HTTP error. On Kinsta you can easily switch to PHP 7.2 with a single click in the MyKinsta dashboard.

How to fix the WordPress HTTP error (uploading the image to the media library)

Change the PHP version

If the host uses cPanel, it may already have an option available to change the PHP version. Just log in to cPanel and under "Software" click on "Select PHP version".

How to fix the WordPress HTTP error (uploading the image to the media library)

Select the PHP version

You can then select the available PHP versions that the host supports.

How to fix the WordPress HTTP error (uploading the image to the media library)

PHP 7 in cPanel

9. Resolve performance issues with Imagick and Shared Hosts

There are two different PHP modules used by WordPress for image processing: GD Library and Imagick (ImageMagick). Depending on what is installed on your server, WordPress can use one of them.

The problem is that Shared WordPress hosts have a lot of throttling of hidden resources behind the scenes. This is the only way they can cram so many users on the same machine. A common problem that people encounter is that there are too few resources assigned to Imagick (ImageMagick). Hosts will restrict the ability to use multiple threads, thus resulting in WordPress HTTP error.

You can add the following code at the beginning of yours .htaccess file, changing the thread limit value to something higher.


Another option you have is to tell WordPress to use the GD library instead of Imagick. You can do this simply by adding the following code to your theme functions.php file.

function wpb_image_editor_default_to_gd ($ editors) {
$ gd_editor = & # 39; WP_Image_Editor_GD & # 39 ;;
$ editors = array_diff ($ editors, array ($ gd_editor));
array_unshift ($ editors, $ gd_editor);
return $ editors;
add_filter (& # 39; wp_image_editors & # 39 ;, & # 39; wpb_image_editor_default_to_gd & # 39;);

We will be frank. If you have to change things like that it's time to move to a new WordPress host. Kinsta has no crazy limits like this and for the most part, you're limited only by PHP workers. You should not worry about these types of things as a website owner.

We use LXD managed hosts and LXC orchestrated software containers for each site. This means that every WordPress site is hosted in its own isolated container, which has all the software resources necessary to run it (Linux, Nginx, PHP, MySQL). The resources are 100% private and they are private not shared among others or even your sites.

Read more about how Kinsta is different from any other host you've tried.

10. Remove the path to the custom media library

It is very likely that the media library path is not configured correctly. We usually see it when users migrate their local development site to production. If you look in "Media" under "Settings" in the WordPress dashboard and you see the value of the file path listed, go ahead and delete it and click "Save Changes". You want the media to be stored in the default setting / Wp-content / uploads folder.

The following is how it looks generally. If you do not see the path of a library, then you're all right.

How to fix the WordPress HTTP error (uploading the image to the media library)

WordPress multimedia settings

11. Disable mod_security

Mod_security is an open source firewall that sometimes could cause WordPress HTTP error. You can disable mod_security by adding the following code at the beginning of yours .htaccess file.

SecFilterEngine Off
SecFilterScanPOST Off

If you are using cPanel, you can also disable it by clicking on "ModSecurity" in the "Security" section.

How to fix the WordPress HTTP error (uploading the image to the media library)

cPanel ModSecurity

Then set the status from "On" to "Off" next to the domain you want to disable it.

How to fix the WordPress HTTP error (uploading the image to the media library)

Disable mod_security

We always recommend using a company-level and at the same time convenient WAF as Sucuri or Cloudflare.

12. Install the Add From Server plug-in

Last but not least, if you're really in a dead end and nothing else seems to work, you can install the free Add From Server plug-in. Maybe you're waiting for a response from your WordPress host or a developer about how to fix the WordPress HTTP error.

How to fix the WordPress HTTP error (uploading the image to the media library)

Add from WordPress server plugin

The Add to Server plug-in allows you to circumvent the error and may be a good temporary solution, especially if you're right in the middle of something important. It was originally developed to allow you to add large files via SFTP. Important: this plugin is no longer maintained or supported. Use at your own risk.


As you can see there are several ways to correct the WordPress HTTP error. We hope that one of the above solutions worked for you and you are already back on track and uploaded your multimedia files. If you continue to receive this error multiple times, it may be time to consider upgrading to a better WordPress host. Many of the solutions above are things you do not need to worry about in Kinsta.

If you have found a solution that is not on our list, please leave a comment below and we will add it.


Source link