Fix WordPress Memory Exhausted Error: Simple Ways to Increase PHP Memory
When your WordPress site shows a “memory exhausted” message or a critical error, it means your site needs more PHP memory than your server allows.
This error often appears when you use heavy plugins, upload large files, or run many tasks at the same time.
The good news is that you can fix this problem in a few simple steps. In this guide, you will learn how to increase the PHP memory limit safely and make your website work again.
What Is the WordPress Memory Exhausted Error?
WordPress runs on PHP. PHP needs memory to load pages, run plugins, and process your theme.
When your site uses more memory than the server gives, WordPress stops running and shows an error.
You may see:
“Allowed memory size exhausted”
“There has been a critical error on this website”
This error happens because your site does not have enough memory to complete a task.
Common causes include:
A heavy plugin that uses too much memory
A theme with large scripts
Many plugins running together
Low memory limits set by your hosting
Uploading large media files
How to Fix WordPress Memory Exhausted Error
Below are the safest and most effective ways to increase PHP memory and fix this issue.
1. Increase Memory in wp-config.php
This is the most common and recommended method.
Steps:
Open your hosting control panel or FTP client.
Go to the root directory of your WordPress site (usually public_html).
Find the wp-config.php file.
Open the file for editing.
Add this line above the sentence:
“That’s all, stop editing!”
define( 'WP_MEMORY_LIMIT', '256M' );
You can increase it more if needed, such as 512M, depending on your hosting plan.
Save the file and reload your site.
If the error is gone, your memory limit was too low, and this fix worked.
2. Increase Memory Using php.ini
Some hosting providers keep a lower memory limit in the server settings.
If wp-config.php does not work, try editing php.ini.
Steps:
Go to your hosting file manager or FTP.
Search for a file named php.ini.
Open it and find the line that starts with:
memory_limit =
Change it to:
memory_limit = 256M
Save the file.
If you cannot find php.ini, your host may not allow this method.
3. Increase Memory Through .htaccess
You can also increase memory by editing the .htaccess file.
Steps:
Go to the WordPress root folder.
Find the .htaccess file.
Add this line at the top or before “# END WordPress”:
php_value memory_limit 256M
Save the file and reload your website.
This method works only on Apache servers. If you use NGINX, this will not work.
4. Contact Your Hosting Provider
If none of the above options work, then your hosting provider may be limiting the memory from their side.
Tell them:
“Please increase my PHP memory limit to at least 256M or 512M.”
If your site is growing, consider upgrading to a higher plan. Many shared hosting plans have low memory limits by default.
5. When You Should Upgrade Hosting
You may need better hosting if:
Your site gets more visitors
You use many plugins
You have an online store
You run large scripts
Your memory limit errors keep coming back
A higher hosting plan gives more resources and better performance.
How to Prevent the Memory Exhausted Error
Here are simple tips to avoid this problem in the future:
1. Remove unused plugins
Inactive plugins still take space and sometimes memory.
Delete plugins you do not use.
2. Use lighter plugins
Choose plugins that are well-coded and updated.
3. Optimize your images
Large images use more resources.
Compress images before uploading.
4. Use a caching plugin
Caching reduces the load on your server and saves memory.
5. Keep your site clean
Regularly update WordPress, plugins, and your theme.
Frequently Asked Questions (FAQs)
1. Why does my site show a “critical error” instead of a memory error?
Newer versions of WordPress hide technical messages for security. The real error appears in your admin email or error logs.
2. How much memory should my site have?
Small sites can work with 128M, but modern WordPress sites should use 256M or more.
3. Can shared hosting cause memory problems?
Yes. Shared hosting gives limited resources. Growing sites often outgrow these limits.
4. Is it safe to increase PHP memory manually?
Yes, as long as your hosting supports it. Always take a backup before editing files.
Final Thoughts
The WordPress Memory Exhausted Error is very common, and it is easy to fix.
Increasing your PHP memory limit will solve the problem in most cases. If the problem keeps coming back, it may be time to upgrade hosting or remove heavy plugins.
A healthy site needs enough memory to run smoothly. With the methods above, you can fix the error fast and keep your website running without stress.