One of the more common errors we’ve seen WordPress users run into, especially on shared hosting, is the memory exhausted error.
Sometimes it shows up with a technical message like “Allowed memory size exhausted.” Other times, WordPress just displays the generic “There has been a critical error on this website” screen.
This usually means your site needs more PHP memory than the server is currently allowed to use. It can happen when you install resource-heavy plugins, upload large media files, or outgrow your hosting plan.
In this guide, we’ll show you how to safely increase your PHP memory limit in WordPress and fix the error. We’ll also share best practices to prevent it from coming back.

What Is the WordPress Memory Exhausted Error?
The memory exhausted error in WordPress usually happens when your website tries to use more PHP memory than your server allows.
This can cause pages to crash, break plugins, or trigger a full-site error. In many cases, you’ll now see a message saying: “There has been a critical error on this website.”

Behind the scenes, the actual error looks something like this:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes)
WordPress is built with PHP, which runs on your server and needs memory to function. If your site pushes past the available memory limit, PHP stops working, and you get this error.
From helping many users fix this, we’ve seen it happen when sites have:
- One or more poorly coded plugins are installed
- Large images or videos that use extra server memory
- Limited hosting resources, especially on shared plans
WordPress does try to increase the memory limit automatically if it’s lower than 64 MB. But in many cases, that’s just not enough, especially for modern plugins and themes.
Why You May Not See the Actual Memory Error
Wondering why you aren’t seeing the actual memory error? This is important to understand before you try fixing it.
In older versions of WordPress, you would often see the full memory exhausted error message directly on your screen.
But in recent versions, WordPress shows a more generic message instead:
“There has been a critical error on this website. Please check your site admin email inbox for instructions.”
This happens because WordPress now hides sensitive error details by default. It’s part of a security feature that prevents visitors from seeing technical information about your site.
However, the real error is still logged in the background. You can view the full message by:
- Looking in the email inbox of your site admin address for instructions.
- Enabling WordPress debug mode in your
wp-config.phpfile. - Checking your site’s error logs via your hosting control panel.
If you check your email inbox you may find an email with subject line “Your Site is Experiencing a Technical Issue.”

Inside this email, you will find where the error occurred and the exact error message.
For instance, you will see that the error is caused by your WordPress theme or a plugin. At the end of the email, you will see the actual error message.

We recommend enabling debug mode only temporarily while troubleshooting. Once you find the error, don’t forget to turn it off to avoid showing technical details to your visitors.
Now, in the next sections, we’ll show you how to manually increase the PHP memory limit to fix the error and keep your site running smoothly.
- Option 1: Editing the wp-config.php File
- Option 2: Editing the .htaccess File
- Option 3: Checking Your php.ini File
- Option 4: Upgrading Your WordPress Hosting
- How to Avoid Exhausting Your WordPress Memory
- FAQs About the WordPress Memory Exhausted Error
- Additional WordPress Error Guides
📝 Note: Some of these methods require you to directly edit your WordPress files. We suggest backing up your website first to avoid further errors from appearing on your website.
Ready? Let’s jump right in!
Option 1: Editing the wp-config.php File
First, you need to edit the wp-config.php file on your WordPress site. This is one of the core WordPress files located in the root directory, usually named public_html.
You will need to use an FTP client like FileZilla or the File Manager in your web hosting control panel.
Next, you need to paste the following line in the wp-config.php file just before the one that says, That's all, stop editing! Happy blogging.
define( 'WP_MEMORY_LIMIT', '512M' );
This line requests WordPress to allocate up to 512MB of PHP memory.
However, the final limit depends on your server’s configuration. If your host enforces a lower cap, this change may not take effect.
For more details, you can see our step-by-step guide on how to find and edit the wp-config.php file.
Once you are done, you need to save your changes and upload your wp-config.php file back to your server.
You can now visit your WordPress site, and the memory exhausted error should have disappeared.
Option 2: Editing the .htaccess File
The next method is to edit the .htaccess file. This file is also located in the WordPress website’s root folder.
Here, you need to paste the following code before the line that says #END WORDPRESS.
php_value memory_limit 512M
Similar to the previous code, it will tell WordPress to increase the PHP memory limit to 512MB.
That said, keep in mind this method only works if your server runs Apache with mod_php. If you’re using PHP-FPM or NGINX, this method may not have any effect.
After that, simply save your changes and upload the file back to your web server. You can now open your WordPress website again to see if the memory limit error has gone.
If you can’t find the .htaccess file, you can check out our guide on why the .htaccess file may be missing and how to find it.
Option 3: Checking Your php.ini File
If the above methods don’t work, you may want to look at your php.ini file.
php.ini is a file that controls your PHP settings, including the PHP version and PHP scripts. It’s not a WordPress core file, as your hosting provider usually manages it.
You can check its code to see your PHP memory usage limit. For more details, you can see our guide on how to find and edit the php.ini file.
However, because this is an advanced method, we recommend contacting your web hosting provider’s support team instead to see if they can increase the WordPress memory limit manually. Otherwise, this can result in further errors.
Plus, some shared hosting plans don’t allow users to access or modify the php.ini file.
You can read our guide on how to properly ask for WordPress support for more information.
Option 4: Upgrading Your WordPress Hosting
If you constantly encounter the memory exhausted error, it might be a sign that your website has outgrown its current hosting plan.
As your website attracts more visitors and adds more content, it requires more resources to function smoothly. Upgrading a plan with a higher memory allocation can be a permanent solution.
Consider upgrading your WordPress hosting if:
- You’ve tried the previous solutions, but the error persists.
- Your website has significantly grown in traffic or content.
- You plan to add features or functionality that require more resources.
Bluehost offers affordable and reliable WordPress hosting plans that can scale with your website’s needs. They provide a user-friendly platform specifically optimized for WordPress, making it easy to manage your website.
If you use our Bluehost coupon code, then you can get up to 61% off your first purchase. Just click the button below to get it:

How to Avoid Exhausting Your WordPress Memory
Now that you’ve fixed the WordPress memory exhausted error, here are some proactive steps to prevent it from happening again:
- Deactivate unused plugins. Many plugins contribute to memory usage. Regularly review your installed plugins and deactivate any you’re not actively using to free up memory for essential tasks.
- Optimize images. Large images can be memory hogs. Consider using a plugin like EWWW Image Optimizer to automatically compress images before uploading them to your site.
- Use a caching plugin. Caching plugins store website data, reducing the need for WordPress to regenerate it on every visit. This can significantly improve website performance and lower memory usage.
FAQs About the WordPress Memory Exhausted Error
What causes the memory exhausted error in WordPress?
This error happens when WordPress needs more memory than your server allows PHP to use. It’s often triggered by resource-heavy plugins, large images, or growing traffic on lower-tier hosting plans.
Why do I only see a “critical error” message instead of the memory error?
Newer versions of WordPress hide the technical error behind a generic “There has been a critical error on this website” message. You can still view the full error by enabling debug mode or checking your error logs.
How much PHP memory should I allocate?
We recommend setting the memory limit to at least 256MB. This is typically enough for most websites unless you’re running a large WooCommerce store or using heavy plugins.
Can shared hosting cause this error more frequently?
Yes. Shared hosting plans often come with limited resources. As your website grows, it can hit those memory limits faster. Upgrading to a better hosting plan can prevent this issue.
Is it safe to increase PHP memory manually?
Yes, it’s safe if done properly. We recommend backing up your website before editing files like wp-config.php or .htaccess. If you’re not comfortable doing this, our Pro Services team can help.
Additional WordPress Error Guides
If you’re troubleshooting other WordPress issues, here are some helpful guides we’ve written to make things easier for you.
- How to Fix WordPress Posts Returning 404 Error (Step by Step)
- How to Fix ‘Cookies Are Blocked Due to Unexpected Output’ Error in WordPress
- How to Fix WordPress Stuck in Maintenance Mode (The Easy Way)
- How to Fix the WordPress Admin Ajax 400 (Bad Request) Error
We hope this article helped you solve the WordPress memory exhausted error by increasing the PHP memory limit. You may also want to see our step-by-step beginner’s guide to troubleshooting WordPress errors and our expert list of the most common WordPress errors.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Michelle
It’s 1:53AM and because of you, I can sleep in peace now. THANK YOU!
Chintan Dave
define( ‘WP_MEMORY_LIMIT’, ‘256M’ ); worked all time. Thank a lot for the solution.
mohammed
you guys are amazing you solved most of the issues i encounter since started working with WordPress.
Siddhartha Gautam
It worked for me. Thanks!
Haley McCalister
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 22 bytes) in /home/nels1max/public_html/ngifts/wp-includes/class-wp-hook.php on line 286
I’ve tried to expand my limit but it didn’t work. When I refresh the page, it changes what’s after “/wp-includes/” and the line number, but none of those files have a place to expand the size. Any tips?
Jordan Casey
Try increasing it to 512M. There still isn’t enough memory for whatever theme you’re running. Good luck! P.S. make sure that you have more than 512M of memory. Ask your hosting provider.
Marcel Dusek
Great! It worked. Thank you so much !!!
Vikas Yadav
Thank you so much for sharing this. Helped me a lot!
Ian
It works! Thanks for the suggestion. But I have a question. I find another article said that changes WP_MEMORY_LIMIT in default-constants.php. Is there any different between this two methods?
Jeff C
I have the same question. Can you explain the difference? Why use one over the other?
WPBeginner Support
The constants file is for settings that don’t change, editing the config file is where you would make changes that can be reverted later when you are no longer receiving the error.
Admin
Joseph Sintum
Thank you very much for this fix.
I was already freaking out…
Ahad Arzi
Thanks man. iT’S REALLY HELPS
Heather
Wow, this worked like a charm and it was easy peasy! Thanks so much!
Peter
Thank you very much! It works
Jane
I looked everywhere for a solution and even called the host searching for an answer. Fixed it PERFECTLY! Thanks so very much!
Ton
Thanks a lot! My problem was solved in 5 minutes!!
kartik
Dear All,
we are getting this error
let me know the solution on it?
Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 8192 bytes) in /home/f036v20tz3th/public_html/wp-includes/functions.php on line 5276
Regards
KARTIK
Desmond Lai
Great! It works well. Thank you so much.
Richie
Thanks for the tips, fixed with the memory line in wp-config
Shehan Disanayake
This was very helpful. Thanks a lot.
Jaime
Thanks so much guys for this article! What is the diference from changing wp_memory_limit (wp-config.php) and memory_limit (php.ini)??? Are the same??
This memory limit is for individual sessions or entire wordpress site?? I ask because if i had 200 visitors in minutes.. i have to go damn higher with this number?? Or try to keep it low??? Hope you can help me with this!
Alexander
Thank you so much!!!
Jeremy
Thank you guys so much for this! I spent the last couple hours trying to figure this out.
Thanks again!
Rick Hunter
Excellent. Thanks so much. Changed to 1024 and it worked like a charm.
Ujenk
When I changed with 512 M it was failed then I put it define( ‘WP_MEMORY_LIMIT’, ‘2000M’ );
And it works well.
/* That’s all, stop editing! Happy blogging. */
Joshua
if that code doesn’t work, rephrase it to
//increase WP Memory Limit
define(‘WP_MEMORY_LIMIT’, ‘256M’);
Néo
It works.
Pascal
Could this be set to 512MB by any chance?
I am hosted by OVH
Thank you!
WPBeginner Support
Yes it can be.
Admin
suraj
worked like a charm and loads faster .. but sure would like to knw the root cause and fix the issue there
suraj
you can change but it maxed out the memory and gave frequent errors of the same, editing posts on wordpress.com also had errors and tags and categories did not populate there.
in WP it seems to work but it lagged considerably.
If you have more memory allocated then you can do it. I am gonna do half of memory allocated by hosting. check cpanel for that.
Dee
Thank you so much! I’ve been waiting for my developer to respond in order to fix it when I could have just done it myself! So much time wasted, thank you for publishing this!!
Brent
Thanks, you da MAN! Fixed my problem
Yakin Shah
This is awesome. just 2minutes, and I got my website back to working. Thanks!
Krista
You ROCK! Easy to follow and it worked! I am web-illiterate and was able to fix it in one go. THANK YOU!
Silvero
Awesome, thank you, you saved my site
Thiago
You guys are great. Thank you so much for the help!
It worked!
Sue Hanson
Thanks a lot for this article. It really helped me out. I was able to fix this problem and get onto building my site.
Lulu
Beautiful, simple fix, thanks so much!!
Morgan Leahy
Before doing any of this…be sure to check your root install directory. I had a blank ‘index.htm’ file that was left by my hosting service, and I completely overlooked it.
Jill
Thank you so much for posting this tutorial! It fixed my website so I could start breathing again!
zac
Worked like a charm… Love the internet!
Dana Jewel
Thank you so very, very much for sharing this tip.
Bharat M
You are rocking men…
Every time I got an problem, I got it solution from here…
Thanks for the awesome article.
Karen Gusler
Thank you!!!! This was a Godsend!!! While trying to troubleshoot why some emails are not being sent via our online form, I installed a plugin and it caused this error. My web site is back up and running!!!! Thank you again!
Renske
By following these steps I have fixed the problem. Thank you SOOOOO much!
Enzo
Excuse me. What could be the cause of this?
Jason Didner
That fixed a number of problems! Being able to change themes; being able to save my widgets – great tip! Spent a lot of time looking for this solution.
Keshav
Thanks a lot!
It works really nice for me.
Thank you so much.
Amir Khan
Thanks a lot fixed my issue Successfully
aisha
this doesn’t resolve my issue
plz now tell me what I can do ?
still error is there
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4114136611 bytes) in C:\xampp\…\wp-includes\functions.php on line 5163
Joel
I get this error quite often. And I am not sure why.
It comes from the function wp_is_stream(). I’m not sure where this is being used that is causing the error.
A bit of investigation showed that if you comment out wp_head() in your header.php file that solves the issue. More specifically, it is something hooked onto the ‘wp_head’ action, and I think one of the filters with priority of 10. Unfortunately, after getting this far, the error magically fixed itself and went away, so I wasn’t able to track down the exact function. Also, wp_is_stream() was only used in 3 or 4 places, so maybe you could find the culprit easier just by checking the usages of that function.
Brandon J
This was amazing. I was skeptical at first since this was my first time ever doing something like this. I finally just went for it and it worked. Thank you so much.
Sahil gour
Thank you so much for explaining everything. it works thanks
Sirisha
This fixed my issue. Thank you for the well-explained article.
Shriram
Thanks a lot, you saved me. You are my go-to site for most of my wordpress related problems!