Fix WordPress "Upload Failed" or "HTTP Error" on Media Upload
WordPress media upload HTTP error causes: PHP memory limits, file size limits, permissions, and image editor issues. How to diagnose and fix each.
The WordPress 'HTTP Error' on media upload is a generic message that can mean PHP memory exhaustion, a file exceeding the upload_max_filesize or post_max_size limit, incorrect file permissions on the uploads directory, or a conflict with the GD/Imagick image editor — enable WP_DEBUG to reveal the actual error.
The WordPress "HTTP Error" or "Upload Failed" message when trying to upload images is one of the vaguest error messages in WordPress. It can mean a dozen different things. Here is how to diagnose which cause applies to your situation and fix it.
Identify the specific error
The generic "HTTP Error" hides the real cause. Before applying fixes, get more detail:
Enable WP_DEBUG temporarily:
In wp-config.php:
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); // don't show errors to visitors
Try the upload again. Then check wp-content/debug.log for the specific PHP error.
Check browser console: Open DevTools > Network tab, then attempt the upload. Look for the XHR request to async-upload.php. Check its response for an error message.
Check server error log:
tail -n 50 /var/log/nginx/yourdomain.com.error.log # or for Apache: tail -n 50 /var/log/apache2/error.log
Cause 1 - File size too large
The most common cause for large images: the upload exceeds PHP's upload_max_filesize or post_max_size limits.
Check current limits: Add this temporarily to any page template to see the current limits:
<?php
echo ini_get('upload_max_filesize') . '<br>';
echo ini_get('post_max_size') . '<br>';
echo ini_get('memory_limit');
Or check via WP-CLI:
wp eval 'echo ini_get("upload_max_filesize");'
Fix via php.ini:
upload_max_filesize = 64M post_max_size = 64M memory_limit = 256M
Location of php.ini varies by server setup:
/etc/php/8.3/fpm/php.ini(PHP-FPM on Ubuntu)/etc/php.ini(CentOS/AlmaLinux)/usr/local/lib/php.ini(some control panels)
After editing, restart PHP-FPM:
sudo systemctl restart php8.3-fpm
Fix via wp-config.php:
@ini_set( 'upload_max_size', '64M' ); @ini_set( 'post_max_size', '64M' ); @ini_set( 'memory_limit', '256M' );
Fix via .htaccess (Apache only):
php_value upload_max_filesize 64M php_value post_max_size 64M php_value memory_limit 256M
Fix in WordPress functions.php: WordPress also has its own upload size filter:
add_filter( 'upload_size_limit', function() {
return 64 * MB_IN_BYTES; // 64MB
});
Note: post_max_size must be larger than upload_max_filesize. If upload_max_filesize is 64M but post_max_size is still 8M (the default), the upload still fails.
Cause 2 - PHP memory exhausted
Large image files require PHP memory to process (resize, create thumbnails). If memory_limit is too low:
# Check if this is the error in debug.log grep "Allowed memory size" /var/www/html/wp-content/debug.log
Fix:
// wp-config.php define( 'WP_MEMORY_LIMIT', '256M' ); define( 'WP_MAX_MEMORY_LIMIT', '512M' );
And in php.ini:
memory_limit = 256M
Cause 3 - File permission error
WordPress needs write permission to the uploads directory. If the web server process cannot write to wp-content/uploads/, every upload fails.
Check permissions:
ls -la /var/www/html/wp-content/
The uploads directory should be owned by the web server user (typically www-data) and have 755 permissions:
sudo chown -R www-data:www-data /var/www/html/wp-content/uploads sudo chmod -R 755 /var/www/html/wp-content/uploads
Check if the uploads directory exists:
ls /var/www/html/wp-content/uploads
If it does not exist:
sudo mkdir -p /var/www/html/wp-content/uploads sudo chown www-data:www-data /var/www/html/wp-content/uploads sudo chmod 755 /var/www/html/wp-content/uploads
Cause 4 - Image editor library problem
WordPress uses either GD Library or ImageMagick to process uploaded images (create thumbnails, resize). If the active library has a bug with a particular image format or is misconfigured:
Check which library is active: Go to Tools > Site Health > Info > Media Handling. This shows which image editor is in use and which formats are supported.
Switch between GD and ImageMagick:
To force GD:
add_filter( 'wp_image_editors', function( $editors ) {
return [ 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ];
});
To force ImageMagick:
add_filter( 'wp_image_editors', function( $editors ) {
return [ 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ];
});
Add to functions.php, test the upload, then remove the code if GD works but ImageMagick does not (or report the issue to your host).
Install missing PHP extensions:
sudo apt-get install -y php8.3-imagick php8.3-gd sudo systemctl restart php8.3-fpm
Cause 5 - Security plugin blocking the upload
Some security plugins (Wordfence, WP Cerber) have file type restrictions that block uploads of certain file types, or rate-limit upload requests.
Test:
- Temporarily deactivate your security plugin
- Attempt the upload
- If it works: the security plugin has a setting causing it
In Wordfence: check "Firewall" settings for file upload restrictions. Wordfence has a "Block upload of PHP files and other executable files" setting that occasionally misidentifies safe files.
Cause 6 - Wrong file type
WordPress has an allowed file types list. By default, it blocks PHP files (for security) and some less-common formats.
If you are trying to upload an SVG, PDF, or other non-default type:
// Add SVG support
add_filter( 'upload_mimes', function( $mime_types ) {
$mime_types['svg'] = 'image/svg+xml';
$mime_types['svgz'] = 'image/svg+xml';
return $mime_types;
});
// Add MIME type check
add_filter( 'wp_check_filetype_and_ext', function( $data, $file, $filename, $mimes ) {
$ext = pathinfo( $filename, PATHINFO_EXTENSION );
$type = false;
$proper = false;
if ( 'svg' === $ext ) {
$type = 'image/svg+xml';
$proper = 'svg';
}
if ( $type ) {
$data['ext'] = $proper;
$data['type'] = $type;
}
return $data;
}, 10, 4 );
Security note for SVG: SVG files can contain embedded JavaScript and present an XSS risk if uploaded by untrusted users. Only allow SVG uploads if you control who uploads them (authors/admins you trust). Use the Safe SVG plugin for sanitisation.
Quick fix checklist
- [ ] Enable WP_DEBUG_LOG and check the actual error in
debug.log - [ ] Verify
upload_max_filesizeandpost_max_sizeare at least 64M - [ ] Verify
memory_limitis at least 256M - [ ] Check uploads directory permissions (www-data owned, 755)
- [ ] Switch image editor from ImageMagick to GD or vice versa
- [ ] Temporarily deactivate security plugin to test
- [ ] Check file type is in the allowed MIME list
Related reading
Frequently Asked Questions
How do I fix the WordPress HTTP error when uploading images?
Why does WordPress upload fail for large images but not small ones?
How do I fix WordPress media upload permission errors?
Can a plugin cause WordPress media upload failures?
// new_articles
Get notified when new guides drop
Practical WordPress guides from a working agency owner. No filler. Unsubscribe any time.
Was this article helpful?
Thanks for the feedback!