Follow us:
If your WordPress site is misbehaving and you’ve enabled debugging, you might run into an error that says something like:
“Allowed memory size of X bytes exhausted”
This error means your website is running out of server memory while processing something—maybe a plugin, theme function, or even media handling. While WordPress now hides these errors from public view, you’ll still see them in the debug log if you’ve turned on WP_DEBUG.
Let’s explore what this error means, why it happens, and how you can fix it by increasing your PHP memory limit.
What Is the “Memory Exhausted” Error in WordPress?
Every WordPress site runs on a web server that allocates memory to execute PHP scripts. If your website demands more memory than what’s available, PHP stops the process—and throws a fatal error.
For example, if you’ve enabled debugging in wp-config.php like this:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
You might find this error in the log file located at /wp-content/debug.log:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 123456 bytes) in /path/to/your/site/wp-includes/plugin.php on line 123
That means your site tried to use more than 128MB of PHP memory.
This error no longer shows publicly to visitors unless you’re in development mode, but it still needs to be fixed to ensure your site works properly.
Why Does WordPress Run Out of Memory?
There are several reasons this error may appear:
- You’re using a resource-heavy plugin or theme
- A plugin is causing a memory leak
- You’re processing large images or files
- Your host allocates very low memory by default (e.g., 64MB)
- A poorly coded script is running indefinitely
Let’s fix it by giving your site more memory.
How to Increase PHP Memory Limit in WordPress
Before proceeding, back up your website. Now, try the following methods—starting from the simplest.
1. Increase PHP Memory via wp-config.php
This is the safest and most reliable way for most users.
- Access your website using FTP or File Manager in your hosting dashboard.
- Locate the
wp-config.phpfile in the root directory. - Open it and add the following line before the line that says
/* That's all, stop editing! Happy publishing. */:
define('WP_MEMORY_LIMIT', '256M');
- Save and upload the file back.
This tells WordPress to request up to 256MB of memory from the server.
Note: If you’re using the WordPress admin area and facing this issue, you can also try increasing the admin memory specifically:
define('WP_MAX_MEMORY_LIMIT', '256M');
Use both lines if needed.
2. Update Memory Limit via Hosting Panel (cPanel, Site Tools, etc.)
If you have access to your hosting control panel, you can often increase memory from there.
For cPanel:
- Log in to cPanel.
- Open Select PHP Version or MultiPHP INI Editor.
- Choose your domain.
- Look for
memory_limitand set it to256Mor higher. - Save the changes.
For SiteGround (Site Tools):
- Go to Dev > PHP Manager.
- Click on the settings for your domain.
- Increase the memory limit value.
Hosting platforms vary, so check your host’s documentation if needed.
3. Modify php.ini File (Advanced)
This method works well on VPS, dedicated hosting, or some advanced shared hosting plans.
- In your site’s root folder, look for a
php.inifile. If it doesn’t exist, create one. - Add this line:
memory_limit = 256M
- Save and upload it.
This overrides the default server configuration—if your hosting provider allows it.
4. Use .htaccess (If php.ini is Not Available)
If your server runs Apache and doesn’t allow php.ini, you can use .htaccess instead.
- In your site’s root folder, open the
.htaccessfile. - Add this line at the bottom:
php_value memory_limit 256M
- Save the file.
Important: If this causes a 500 Internal Server Error, remove the line immediately. Some hosts don’t support changing memory through .htaccess.
Not Working? Contact Your Host
Some web hosting providers restrict PHP memory usage at the server level and do not allow users to override it. If none of the above methods increase the limit, reach out to your host’s support team and ask them:
“Can you please increase my PHP memory limit to 256MB or higher?”
Most providers will be happy to help, especially if you’re on a managed WordPress or business hosting plan.
How Much Memory Do You Actually Need?
Here’s a quick guide:
- 64MB – Absolute minimum; often too low
- 128MB – Suitable for blogs and simple websites
- 256MB – Recommended for most sites with multiple plugins
- 512MB+ – Ideal for eCommerce, LMS, and high-traffic sites
If your site handles image processing, WooCommerce, or page builders like Elementor, more memory will give better stability and performance.
Final Thoughts
The “memory exhausted” error isn’t as scary as it sounds. Even though WordPress now hides it from public view, it still needs to be addressed behind the scenes. Increasing the PHP memory limit using wp-config.php, your hosting dashboard or server configuration will usually solve it in minutes.
Still stuck? Disable plugins one by one to find the culprit—or reach out to your host.
Want more WordPress fixes? Stick with WP Passion, where solving WordPress problems is our passion.



