Fix Memory Exhausted Error – Increase PHP Memory in WordPress

If you’ve ever come across a fatal error message saying “Allowed memory size exhausted” on your WordPress website, don’t worry—you’re not alone. This is a common error, and the good news is that it’s easy to fix this Memory Exhausted Error.
In this guide, we’ll walk you through what causes the WordPress memory exhausted error and how to increase PHP memory in WordPress like a pro, even if you’re not a developer. Let’s fix it step-by-step!
1. What is the WordPress Memory Exhausted Error?
WordPress is built using PHP, a server-side programming language. Your web hosting server allocates a specific amount of memory that PHP scripts can use. When your website exceeds this limit, WordPress throws a fatal error like this.
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate XXXX bytes)
This is known as the WordPress memory exhausted error, and it usually happens when plugins, themes, or custom scripts consume more memory than what’s available.

2. Common Causes of PHP Memory Exhaustion
Let’s understand what might be eating up your memory:
- A poorly coded plugin or theme
- Too many active plugins
- Heavy processes (image imports, backups, etc.)
- High-site traffic or large database queries
- Shared hosting with low memory allocation
By default, WordPress tries to allocate 40MB for single sites and 64MB for multisite installations, which is often not enough.
3. How to Increase PHP Memory in WordPress (Step-by-Step)
Here are different methods to increase the PHP memory limit on your WordPress site. You can try them based on the level of access your hosting provider gives you.
1. Increase Memory via wp-config.php
This is one of the safest and most commonly used methods.
Steps:
- Log in to your hosting panel (cPanel/File Manager or FTP).
- Locate the
wp-config.php
file at the root of your WordPress installation. - Add the following line just before the line that says
/* That's all, stop editing! */
:
define(‘WP_MEMORY_LIMIT’, ‘256M’);
This tells WordPress to raise its memory limit to 256MB.
2. Modify the php.ini File
This is ideal for users on VPS or dedicated servers.
Steps:
- Access your hosting panel and go to your file manager or use FTP.
- Look for the
php.ini
file in the root or public_html folder. - Add or edit the following line:
memory_limit = 256M
Save the file and check if the error has been resolved.
3. Edit .htaccess File (Advanced)
If your host supports it, you can use the .htaccess
file to change memory settings.
Steps:
- Go to your WordPress root directory.
- Open or create a
.htaccess
file. - Add the following line:
php_value memory_limit 256M
Note: This may not work on all shared hosts and could result in a 500 error. Test carefully.
4. Hosting Panel Option (For Beginners)
Some hosting providers like Hostinger, Bluehost, or SiteGround provide an option to increase memory from their dashboard.
Steps:
- Log in to your hosting account.
- Go to the PHP settings or PHP configuration area.
- Look for the “memory_limit” field and change it to
256M
or higher. - Save changes.
5. Still Not Working?
If none of the methods are working, your host may have a server-level restriction.
Here’s what to do:
- Contact your hosting support
- Request them to increase your PHP memory limit
- If needed, consider upgrading to a better hosting plan
6. Pro Tips to Avoid Running Out of Memory
Even after fixing the issue, memory exhaustion can return if your site isn’t optimized. Here are a few smart habits:
- Deactivate and delete unused plugins
- Use lightweight themes
- Optimize images before uploading
- Install a caching plugin (like WP Rocket or W3 Total Cache)
- Avoid auto-importing large files frequently
7. How Much Memory Should You Allocate?
- For blogs and small business sites: 128MB – 256MB is sufficient.
- For WooCommerce stores or membership sites: 256MB – 512MB is better.
- If you’re running custom applications or large sites: 512MB or more might be needed.
8. Quick Summary
Method | Description |
---|---|
wp-config.php | The easiest method to set a memory limit |
php.ini | Server-level change for memory limit |
.htaccess | Conditional method works on some servers |
Hosting Panel | Use GUI to increase memory via settings |
Hosting Support | Ask for assistance if all else fails |
Frequently Asked Questions (FAQ)
Q: What is the default memory limit in WordPress?
A: It’s usually 40MB for regular sites and 64MB for multisites but can vary based on your host.
Q: Is it safe to increase PHP memory?
A: Yes, increasing memory helps improve stability and performance. Just ensure your hosting plan supports it.
Q: What’s the ideal PHP memory limit for WooCommerce?
A: At least 256MB is recommended, though 512MB offers smoother performance for larger stores.
Q: What happens if I set the memory too high?
A: It won’t break your site, but the server may ignore it if it exceeds its limits.
Q: Can plugins help with this?
A: While some plugins let you view current memory usage, they can’t override server restrictions like the methods above.
📝 Final Thoughts
Running into the WordPress memory exhausted error can be frustrating, but now you know exactly how to fix it. Whether it’s through editing wp-config.php
, updating php.ini
, or getting help from your hosting provider, solving the problem is easier than it sounds.
By increasing the PHP memory limit, you make your site more stable, more scalable, and ready for growth. Don’t let a technical error slow you down—your website deserves peak performance!