You click Update on a plugin, upload a large image or open a busy dashboard page, and WordPress stops with a message like this:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /home/user/public_html/wp-includes/...
That long number is simply 128 MB written in bytes. The error means a PHP process hit the maximum amount of memory it is allowed to use and was stopped. It sounds serious, but it is usually easy to fix. This guide shows you how to raise the WordPress memory limit and how to find out what is using so much memory in the first place.
What the memory limit actually is
Every time someone loads a page, PHP runs WordPress, your theme and your plugins. Each of those requests is allowed to use a set amount of memory, defined by the PHP setting memory_limit. This cap protects the server: one runaway script cannot consume all of the memory and take down every site on the machine.
WordPress has its own setting on top of that:
- WP_MEMORY_LIMIT: the memory WordPress requests for front-end pages. WordPress defaults to 40 MB on single sites and 64 MB on multisite, but will use the higher PHP limit if one is set.
- WP_MAX_MEMORY_LIMIT: the memory for admin tasks such as updates and image processing. The default is 256 MB.
WordPress cannot go above the limit set by PHP on the server, so sometimes you need to change both.
Common causes
- Heavy plugins, such as page builders, ecommerce, backup, security scanners and analytics dashboards
- Too many plugins running on every page load
- Large image uploads, since resizing big photos takes a lot of memory
- Imports and exports of large XML or CSV files
- A badly coded plugin or theme with a memory leak or an endless loop
Step 1: Check your current limit
Go to Tools → Site Health → Info and expand Server and WordPress Constants. You will see the PHP memory limit and the WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT values.
If you cannot reach the dashboard, the error message itself tells you the limit that was hit.
Step 2: Increase the limit in wp-config.php
Open wp-config.php in your site's root folder using your hosting file manager or SFTP. Above /* That's all, stop editing! */, add:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
Save the file and reload the page that failed. For most small and medium sites, 256 MB is a sensible ceiling. Going much higher rarely helps and can hide a real problem.
If the error still shows the same old number, the PHP limit on the server is lower and is overriding WordPress. Move on to step 3.
Step 3: Raise the PHP memory limit
There are a few ways to do this. Use the one your hosting supports.
In cPanel
- MultiPHP INI Editor: choose your domain, find
memory_limitand set it to256M, then apply. - Select PHP Version → Options: on CloudLinux servers, change
memory_limitin the Options tab.
In DirectAdmin
Look for a PHP settings or PHP Selector option where you can change memory_limit. If you do not see one, your host can raise it for you.
With a php.ini or .user.ini file
On many shared servers you can create or edit a .user.ini or php.ini file in your site's root folder with:
memory_limit = 256M
Changes to .user.ini can take a few minutes to apply because PHP caches the file.
With .htaccess (Apache with mod_php only)
php_value memory_limit 256M
On servers running PHP as a separate handler, which is common today, this line causes a 500 Internal Server Error. If that happens, remove it immediately and use one of the methods above.
Step 4: Confirm the change
Return to Tools → Site Health → Info and check that the PHP memory limit shows the new value. Then repeat the action that caused the error.
Step 5: Find what is using the memory
Raising the limit treats the symptom. If you had to go higher than 256 MB, or the error keeps coming back, find the cause:
- Note where the error points. The file path in the message often contains a plugin or theme folder name, such as
wp-content/plugins/some-plugin/. - Deactivate plugins one by one. If the dashboard is unreachable, rename the
wp-content/pluginsfolder to disable them all, then rename it back and reactivate plugins individually. - Use a diagnostic plugin. Tools like Query Monitor show memory use and slow database queries for each page.
- Resize images before uploading. A photo straight from a modern phone or camera can be several thousand pixels wide. Scaling it down first saves memory and disk space.
- Split large imports into smaller files.
When to talk to your host
You may have reached the limit of your plan if:
- Your plan has a hard memory cap you cannot change
- The site needs a lot of memory just to run normally
- You see memory errors alongside slowness during busy periods
At that point, ask your host what limits apply to your account and whether a larger plan would help. Our guide to hosting resource limits explains how memory, CPU and process limits work on shared hosting.
Wrap-up
The "Allowed memory size exhausted" error means PHP ran out of the memory it was allowed. Add WP_MEMORY_LIMIT to wp-config.php, raise the PHP memory_limit in your control panel if needed, and confirm the change in Site Health. Then find the plugin, image or import that caused the spike, so your site runs well without needing ever-larger limits.