Are you seeing an allowed memory size exhausted error message in WordPress?
This is one of the most common WordPress errors, and you can easily fix it by increasing the PHP memory limit in WordPress.
In this article, we will show you how to fix the WordPress memory exhausted error by increasing the PHP memory limit.

What Is the WordPress Memory Exhausted Error?
WordPress is written in PHP, which is a server-side programming language. Additionally, every website needs a WordPress hosting server for it to function properly.
Web servers are just like any other computer. They need memory to efficiently run multiple applications at the same time. Server administrators allocate specific memory size to different applications, including PHP.
When your WordPress code requires more memory than the default allocated memory, you will see this error message:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx

By default, WordPress automatically tries to increase the PHP memory limit if it is less than 64MB. However, 64MB is often not high enough.
Having said that, let’s see how to easily increase the PHP memory limit in WordPress to avoid the memory exhausted error.
Increase the PHP Memory Limit in WordPress
First, you need to edit the wp-config.php file on your WordPress site. It is located in your WordPress site’s root folder, and you will need to use an FTP client or file manager in your web hosting control panel.
Next, you need to paste this code in the wp-config.php file just before the line that says, ‘That’s all, stop editing! Happy blogging.’
define( 'WP_MEMORY_LIMIT', '256M' );
This code tells WordPress to increase the PHP memory limit to 256MB.
Once you are done, you need to save your changes and upload your wp-config.php file back to your server.
Alternatively, you can use WPCode to insert this code snippet. It is the best WordPress code plugin that allows you to insert code snippets into your site’s files without editing them directly.
For more details, please see our guide on how to easily add custom code in WordPress.
You can now visit your WordPress site, and the memory exhausted error should have disappeared.
We also have a step-by-step guide on how to find and edit the wp-config.php file.
Note: If this solution does not work for you, then this means your web hosting service provider does not allow WordPress to increase the PHP memory limit. This is common if you are using shared hosting. You will need to ask your web hosting provider if they can increase your WordPress memory limit manually.
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, along with our expert picks for the best WordPress plugins to grow your site.
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.
Adam says
Thanks for this article, we’ve been having this problem too.
Which setting takes priority?
In WHM (MultiPHP INI Editor), memory_limit is set to 32M.
In wp-config.php WP_MEMORY_LIMIT is set to 96M.
WPBeginner Support says
Normally wp-config but it would depend on your specific hosting and the settings.
Admin
Edgar says
A lot of thanks!
WPBeginner Support says
You’re welcome
Admin
arjun says
but what exactly is this wordpress memory limit, like how much amount of RAM should wp use on the server? can anyone please share about what this thing is?
thanks
WPBeginner Support says
The memory limit tells WordPress how large requests/files can be for individual tasks, this is not for your site’s RAM and your RAM usage would be determined by what is on your site.
Admin
fazan says
thanks you wpbeginner
you solve my problom
but i have vps , can i increes more memory limit
please reply
WPBeginner Support says
You would need to reach out to your hosting provider for what is available to you
Admin
Ionut Pomirleanu says
Thanks wpbeginner
WPBeginner Support says
You’re welcome
Admin
Ananth Gurunathan says
Thanks for the post. It really worked out for me for my problem which was a big head ache for last 5days. Thanks a lot.
WPBeginner Support says
You’re welcome, glad we could help solve the issue
Admin
Sandeep says
Thanks wpbeginner for this article, i have solved my problem with the help of this article
WPBeginner Support says
You’re welcome, glad our guide could be helpful
Admin
Shahid says
Thanks.. That worked like a charm
WPBeginner Support says
Glad our article could help
Admin
Handsome says
Thank you so much. That worked great for me!
WPBeginner Support says
Glad our recommendations could help
Admin
Ankur Verma says
It works! Thank You.
WPBeginner Support says
Glad our article could help
Admin
Peter says
There needs to be a way to figure out these memory issues without taking the entire site offline or risking breaking the configuration by disabling essential components. Furthermore, the errors are occurring even when the memory limit is set to the maximum physical memory on the server (32GB) and while they are occurring there is no actual spike in memory usage (system utilities are reporting no increase in actual physical memory use.
WPBeginner Support says
You could create a staging site or download your site to a local version: https://www.wpbeginner.com/wp-tutorials/how-to-move-live-wordpress-site-to-local-server/
You could also reach out to your hosting provider to see if they have any errors on their end that they can see.
Admin
Peter says
Useless when the issue does not depend on actual required memory – in my case it keeps giving the error for random plugins no matter how much memory I specify (up to 32GB). Would be nice to know an actual troubleshooting method to see what is using the memory.
WPBeginner Support says
For the steps involved in troubleshooting, you would want to follow our article here:
https://www.wpbeginner.com/beginners-guide/beginners-guide-to-troubleshooting-wordpress-errors-step-by-step/
Admin
Yash Trivedi says
Correct Solution for me…..Thank You So much wpbeginer
WPBeginner Support says
Glad our article could help
Admin
Saran says
Solved. Many Many thanks bro
WPBeginner Support says
Glad our article could help
Admin
Achraf says
I love you ! you’re a life saver !
WPBeginner Support says
Glad our article could help
Admin
Wim Hoogenraad says
I wish I known that earlier. Now | lost a lot of traffic for my site.
Hopefully it is fixed now!
WPBeginner Support says
Hope our article helped you resolve the problem
Admin
Yaseen Ghafar says
Done (y) nice work
thank you
WPBeginner Support says
Glad our article could be helpful
Admin
mrTF says
Thank you so much. That worked great for me!
WPBeginner Support says
Glad our article could help
Admin
CBo says
Worked Great! Thanks!
WPBeginner Support says
Glad you like our content
Admin
ikram says
Great! It works well. Thank you so much.
WPBeginner Support says
You’re welcome
Admin
Krish says
Dead on !! Thanks a lot.
WPBeginner Support says
Glad you like our content
Admin
daniel coelho says
thanks! perfect now!
WPBeginner Support says
You’re welcome
Admin
Pramod Walke says
IT’s working
Thanks a lot.
WPBeginner Support says
You’re welcome
Admin
Mara says
It works, thank you <3
The error was:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 491520 bytes) in…
WPBeginner Support says
Glad our article could help
Admin
Moses Asiago says
Thank you, this helped me alot to kikstart in learning woocommerce
WPBeginner Support says
Glad our guide could help
Admin
EAT (my actual initials) says
Thank you so, so, so, sooooooooooo, so much! I guess as I add more posts to the database it requires more memory to operate. Various things were breaking with this internal error over the course of a couple of years, but since I could still make new posts I just said to myself, “meh, carry on.”
Then I could no longer post! Panic! Everybody PANIC!!!
I enabled debug mode. I got my debug report. I saw the memory exhausted reported. Then I found this page and gave it a try, thinking, “This probably won’t work. I’ve made too many changes to the theme and some of the plugins to work the way I want. Something somewhere got MuNgEd.
Nope. Not at all. This one line of code solved it and got be back up and RUNNING!!!! Yay for me!!!! YAY FOR YOU!!!!
WPBeginner Support says
Glad our guide could help
Admin
NotMyRealName says
Thanks, it worked for me
WPBeginner Support says
Glad our guide could help
Admin
Juman says
That’s worked with me. Thanks a million
WPBeginner Support says
Glad our article could help
Admin
Mykola says
And if you have same problem in admin page you can also try
define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ );
Administration tasks require much memory than usual operation. When in the administration area, the memory can be increased or decreased from the WP_MEMORY_LIMIT by defining WP_MAX_MEMORY_LIMIT.
WP_MAX_MEMORY_LIMIT sets the maximum just on admin pages. It’s a terrible naming scheme but it dates back to WordPress 2.5 and nobody dares change it now
WPBeginner Support says
Thanks for adding this information for other users
Admin
Aniekan says
Thank you so much. It works very fine.
WPBeginner Support says
Hi Aniekan,
Glad you found it helpful.
Admin
Bethany Snyder says
Thank you so much for this quick and easy fix!
WPBeginner Support says
Glad our guide was helpful
Admin
Albert Wesquer says
Thanks man
Manal Shaikh says
Thank you very much. It really worked.
Kerry Rixon says
Thank you Thank you Thank you!
A novice fixed this problem with your help! Thanks again
WPBeginner Support says
You are welcome
Admin
Laura Mailleux says
I have tried this, and now my entire admin panel and website are down, all blocked by that 500 error…. I cannot access anything anymore, and therefore can’t use the File Manager again to remove the change. I’m completely lost, any chance you can help me?
WPBeginner Support says
Hi Laura,
If you have access to cPanel dashboard then you can undo the changes from the file manager section there. Alternately, you can contact your hosting provider to help you fix this.
Admin
prashant says
i have to use wpml plugin issue is english language text editor working properly but when i text german or spanish language (secndery languages ) text editor cant showing on secndery languages text editor so ghow to fix that problem
Jose says
I contacted my hosting company and requested them to increase my PHP memory, this resolved the issue.
Abdultawab Ibrahim says
works like magic.. keep doing the good work
Natangwe says
Thanks A Lot ! Saved me.
Editorial Staff says
Happy to help
Admin
Jonathan says
Help! i have this problem
Allowed memory size of 268435456 bytes exhausted (tried to allocate 10489856 bytes)
WPBeginner Support says
Hi Jonathan,
Please see our article on how to increase php memory limit in WordPress.
Admin
OMAR CHAVEZ says
Gracias !!!
Clarence says
Thank you! Thank you! Thank you! VERY Helpful!
Majid Korm says
Thank you very much
My issues got solved completely based on your detailed information and help.
many many thanks
Majid
Jonny says
I’m not as good at this stuff as I need to be, so I’m still struggling with this.
I open the config.php file and there is a part that says:
define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
only it already says:
define(‘WP_MEMORY_LIMIT’, ‘1024M’);
I’ve changed that to 2048 and 4096 with no change.
But there is no ‘That’s all, stop editing! Happy blogging.’
after the
define(‘WP_MEMORY_LIMIT’, ‘1024M’);
it says
define(‘WP_DEBUG’, false);
then
# That’s It. Pencils down
It does say ‘That’s all, stop editing! Happy blogging.’ in the Sample config.php but not in the actual one.
Any advice?
Jake says
Thank you this worked perfectly!
John Grimes says
Thanks…just moved from Joomla to WordPress and hit this issue. Thanks for the easy fix.
Jenish Parmar says
You are genius. Thanks A Lot ! Saved me.
Ant says
You are a life saver. I was about to start throwing breakable objects.
Scarlett says
Omg, this fixed it! THANK YOU!!!
lokesh says
Thanks for sharing this information, it really helped me to fix word press website.