As a WordPress user, every so often you may come up against a common error. One of which might be when you’re uploading an image or media file to the WordPress media library. This may even randomly happen, even if you haven’t done anything differently.
There are several reasons why this error can occur, but luckily if it all of a sudden starts happening then it’s usually quite a simple fix. This post will show you the different ways to solve this problem and prevent it from happening again.
The solutions covered in this post
- Clear your browser cache or switch web browsers
- Lower the size of the image
- Compress the file size of the image
- Check the image format
- Rename the image file name (remove apostrophes)
- Update the PHP version
- Deactivate plugins
- Switch to default theme
- Increase the PHP memory
- Incorrect file permissions
- Check the debug log
1. Clear your cache (or switch browsers)
Sometimes it could just be a temporary glitch with your hosting, so wait a few minutes, refresh the page and try uploading the image again. If you’re still getting the error, clear your browser cache or switch to a different web browser as it may be unrelated to your website.
2. Change the image size, file size and/or format
If the image is quite large, try reducing its pixel size (width and height) and uploading a smaller size. You could also try compressing the image’s file size or changing the file to a different format (like using jpg instead of png).
3. Rename the image file name
Another common reason for this error is the file name. Try renaming the file and remove any apostrophes, semi-colons or other special characters in the name and try again.
4. Check your PHP version
WordPress currently requires PHP version. 7.4 or greater. A lot of hosts are still using older PHP versions so this may be the cause of your issue. I have a post explaining how to check and update your PHP version on WordPress.
5. Temporarily deactivate plugins
You may have installed a plugin that’s causing this issue. If you’ve recently installed or updated a plugin, deactivate that one first to test for conflicts. If you have an image optimisation plugin, disable this next.
If that doesn’t fix it, then proceed to disabling one plugin at a time to test for conflicts or issues. If it is a plugin issue, you may have to look for an alternative plugin to contact the developer for further help.
6. Switch to default theme
If your theme has recently been altered or updated, then this may be causing the issue. Backup your site and then switch to a WordPress default theme (like Twenty Sixteen or Twenty Seventeen). If the problem is solved, then it’s a theme issue so you’ll need to contact your developer. It could also be a hosting related issue as some theme’s have certain requirements.
7. Increase the memory limit
Another common reason for this error is to do with the lack of available memory to complete the process. To fix this, you need to increase the PHP memory on your server.
To do this you need to access your site via FTP and find this line of code in your
Change this to the following
define( 'WP_MEMORY_LIMIT', '256M' );
If you can’t find this line, then you can add it yourself. This code increase the WordPress memory limit to 256MB, which may solve your upload issue.
Note that this will only work if your host allows you to increase the limit and if your plan allows for it (you can check the PHP info for details). You may want to speak to your host support team directly and ask them to help with this.
8. Incorrect file permissions
An update on your server might have occurred that changed the file permissions. To check and fix this, access your site via FTP and locate the
wp-content folder. Inside, you’ll find an uploads folder, which stores all of the media files you’ve uploaded. Right click on the uploads directory and select File Permissions to be what is recommended by WordPress.
First you need to set the file permissions for the uploads directory and subdirectories to 755. Do this by typing 755 into the Numeric Value field and selecting the “Recurse into subdirectories” and “Apply to directories only” options.
You’ll see the FTP client changing the permissions. Once done, you’ll then need to set the file permissions for the files in the uploads directory to 644. Type 644 into the Numeric Value field, select “Recurse into subdirectories” and “Apply to files only”.
9. Check the Debug Log
If you’re still getting the error, then you can enable debug mode to locate the exact cause of the issue. To do that access your site via FTP and open your
wp-config.php which should be in the root folder of your WP installation.
Find the following line:
and change it to the following:
Underneath that, add the following to your
This will output the errors output to a debug file. Now try to upload the image again, once you see the error go to the debug.log file located in your
wp-content folder. This will give you further details and should show the exact location or cause of the issue.
As you can see there are a few different ways to fix the HTTP error when uploading an image or another media item on WordPress. Hopefully one of the solutions above worked for you. If not, I do offer a Code + Consult service and can help you solve this issue.