How to Fix "Maximum Upload Size Exceeded" and "Memory Exhausted" Errors in WordPress
2 free files — jump to downloads
On this page
- Understand the four PHP limits
- Step 1: Check your current limits
- Step 2: Raise the limits in your hosting panel (best method)
- Hostinger hPanel
- cPanel hosts
- Step 3: Raise WordPress's own memory limit (wp-config.php)
- Step 4: Use a .user.ini or php.ini file
- Step 5: The .htaccess method (last resort)
- If the limit still will not change
- When memory errors keep coming back
- Prevent it next time
- Download the files
You try to upload a theme, a plugin or a large image and WordPress stops you with "The uploaded file exceeds the upload_max_filesize directive in php.ini" or "Maximum upload file size: 2 MB". Or the site suddenly shows "Fatal error: Allowed memory size of 134217728 bytes exhausted". Both are limits set by your server's PHP configuration, and both are usually quick to fix.
This guide explains what each limit means, how to see your real values and four ways to raise them, starting with the safest.
Understand the four PHP limits
- upload_max_filesize: the largest single file you can upload.
- post_max_size: the largest total form submission. It must be equal to or bigger than upload_max_filesize, or uploads still fail.
- memory_limit: how much memory one PHP request can use. Page builders, WooCommerce and imports need more.
- max_execution_time: how many seconds a request can run before it is stopped. Large imports and backups need longer.
The maximum upload size WordPress shows on Media > Add New is the smaller of upload_max_filesize and post_max_size.
Step 1: Check your current limits
- In WordPress, go to Tools > Site Health > Info and open the Server section to see the PHP limits.
- Or install the free SWS Site Fixer plugin (download below) and open Site Fixer > Site Health. It shows the real limits in plain English, flags anything too low in red, and tells you exactly what to change.
Step 2: Raise the limits in your hosting panel (best method)
Changing the values where PHP is actually configured is the most reliable fix.
Hostinger hPanel
- Open your website in hPanel and go to Advanced > PHP Configuration.
- Open the PHP options tab.
- Set upload_max_filesize and post_max_size to 128M, memory_limit to 256M and max_execution_time to 300, then save.
cPanel hosts
Look for Select PHP Version > Options or MultiPHP INI Editor, choose your domain and change the same values.
Reload Media > Add New; the maximum upload size should now show the new value.
Step 3: Raise WordPress's own memory limit (wp-config.php)
WordPress has its own memory setting that can sit below the server limit. Add these lines to wp-config.php, above /* That's all, stop editing! */:
define( 'WP_MEMORY_LIMIT', '256M' ); define( 'WP_MAX_MEMORY_LIMIT', '512M' );
WP_MEMORY_LIMIT applies to the front end and WP_MAX_MEMORY_LIMIT to the admin area. They cannot go higher than the server's memory_limit, so do Step 2 first.
Tip: download a backup copy of wp-config.php before editing. If the site breaks after saving, upload the backup and it comes straight back.
Step 4: Use a .user.ini or php.ini file
If your host has no PHP settings panel, many servers read a file named .user.ini (or php.ini) in the WordPress folder. Create it with:
upload_max_filesize = 128M post_max_size = 128M memory_limit = 256M max_execution_time = 300
Changes in .user.ini can take a few minutes to apply because the server caches it.
Step 5: The .htaccess method (last resort)
On some Apache servers you can add php_value lines to .htaccess. On servers that do not support it, this causes a 500 error, so remove the lines immediately if the site breaks. The snippets file below includes the exact lines.
If the limit still will not change
Your hosting plan has a ceiling you cannot exceed yourself. Contact your host's support and ask them to raise upload_max_filesize, post_max_size and memory_limit. If you need a large plugin or theme installed today, you can also upload its zip folder (unzipped) through File Manager or FTP into wp-content/plugins or wp-content/themes, which bypasses the browser upload limit.
When memory errors keep coming back
If "memory exhausted" returns even with a generous limit, something is using far too much memory:
- Read the full error. The file path after "in" often names the plugin or theme responsible.
- Deactivate recently installed or updated plugins one by one on a staging copy.
- Check for very large imports, image processing on huge photos or runaway background jobs.
- Follow our critical error guide to turn on the debug log and find the exact cause.
Prevent it next time
- Compress images before uploading. Phone photos do not need to be 8 MB; see the speed guide.
- Host videos on YouTube and embed them instead of uploading MP4 files to the media library.
- Delete plugins you do not use; heavy plugins increase memory use on every page.
- Check Site Health after moving hosts, because limits often reset to low defaults.
Download the free plugin and the limit snippets below. New site on Hostinger? The Hostinger setup guide shows the right PHP settings from day one.
Download the files
Free to use in your own and client projects · no sign-up · tested before upload. Always try files on a staging site first and keep a backup.
-
SWS Site Fixer plugin (free WordPress plugin)sws-site-fixer-v1.0.0.zip · 25.8 KB · v1.0.0Download SWS Site Fixer plugin (free WordPress plugin) (25.8 KB)
-
Upload size & memory limit snippetsupload-size-and-memory-limit-snippets.txt · 1.2 KB · v1.0Download Upload size & memory limit snippets (1.2 KB)
Download not working? Tell me and I'll fix it.
Frequently asked questions
What is a good upload size limit for WordPress?
For most sites, 64 MB to 128 MB is plenty for themes, plugins and images. Video-heavy sites may need more, but it is usually better to host large videos on YouTube and embed them.
What memory limit should WordPress have?
256 MB is a comfortable limit for most WordPress sites, including WooCommerce and page builders. The admin area can use up to the WP_MAX_MEMORY_LIMIT value, often set to 512 MB.
Why did my change not work?
Your hosting plan has its own maximum, and some settings files are ignored depending on how PHP runs on your server. Use your host's PHP settings panel first, and if the limit still does not change, ask support to raise it.
Can a memory exhausted error be caused by a plugin?
Yes. A buggy or heavy plugin can use far more memory than normal. If the error continues after raising the limit, check the error message for the plugin path and test by deactivating that plugin.
Is it safe to edit wp-config.php?
Yes, if you download a backup copy first and paste new lines above the 'That's all, stop editing!' comment. A typo can break the site, but restoring the backup copy fixes it immediately.


