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.
Nilanjan Roy says
That fixed my issue too Thanks a lot
Alasdair MacNeill says
This fixed my issue – thank you for the advice!
Momodu Oladapo Ibraheem says
Thanks works for me!!! Your site has been a source of refuge always for WP
Great article, i encountered this problem when i installed a new wordpress theme. While you have accurately told us how to solve this problem, i’m thinking what is the impact of having a website that runs on high php memory on web hosting resources, etc?
WPBeginner Support says
It depends. If you are on shared hosting and your website is continuously using more memory than it should, then your web host will automatically kill that particular process.
Aaron Silva says
Thanks a lot! it worked!!!!!
Olayika Olumayokun says
Thanks so much for this type of post, really helped.
Waqas Gulraiz says
I always forget how to fix this error when I encounter it. Luckily I found your post, and it worked like a charm. Panic mode is now over. Thank you!
I had to edit php.ini and increase memory_limit from 64M to 256. It worked fine!
Updating the php.ini file from 32M to 64M worked for me! Thanks!
Thank you, this helped me a lot!
Cole Ryan says
Simple. Effective. Thank you.
Jos Schuurmans says
Thanks for the tut, good stuff!
QUESTION: After increasing from the default 64M to 256M, my white screen disappeared and the site is up. Is there a reason to scale down the memory again?
WPBeginner Support says
No, you can continue using the new memory limit.
Today is the second time that I’ve needed to refer to this post (bad memory – much like my site).
Great info, keep up the fantastic work.
God bless you guys!!!
Thank you, this article helped me a lot!
How can I mixed this error?
Fatal error: Allowed memory size of 176160768 bytes exhausted (tried to allocate 78 bytes) in /home/brandkpl/public_html/wp-includes/taxonomy.php on line 3146
Is there a way to increase the memory and make sure it stays that way when updating WP?
Everything I update my site, I have to do it all over again…
Thanks for your help!
i also found that there could be a chance that in the root folder there will be a “maint” folder, although normally this will give you a screen saying its under maint which you will then know what to do.
but in my instance the “Maint” in the root folder just showed the WSOD once it was removed i was back up and running.
its working , thanks
Thank you so much
Thank you so much! Helped like a charm!
What a legend!! Been frustrated by this all weekend and now sorted
Thanks a bunch!
Nitin Yadav says
Allowed memory size of 67108864 bytes exhausted (tried to allocate 229376 bytes)
My Problem is this
Thank you! It’s been a while since I ran into this problem and forgot how to fix it!
this saved me hours of struggle, thank you so much!
Nice one, i wonder I could increase the memory of instant wp aplication in order to successfully migrate my blog in blogger to wordpress.
OMG! Thanks so much for this article.
Thank you so much.. works perfectly..
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 78 bytes) in /home/xxxx/public_html/wp-includes/wp-db.php on line 1837
lexspark daville says
increasing the memory limit worked for me….thanks a lot
Vikash Kumar says
Thanku you soo much… i was facing this issue and your post saved my day
Neha Srivastava says
i am getting this error, while importing demo and uploading plugin.
i have already try out these methods. pls help.
500 – Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
Sue P. says
Thank you, it worked!
I increased the limit to 128M but the same problem. Then I increased it to 256M and now its working fine.
Thank you! Worked like a charm!
Amit Sharma says
Now its working. Thanks a lot for sharing such a great information.
work like charm thank you very much…..
Hi, this sounds like the issue I’m having with Prophoto – however I can’t login to the admin area – as I get a blank white screen – to make the changes you suggest, is there another way? Thanks so much
Hey, I probably have a huge problem here.. but the only wp-config file I can find on my Air is wp-config-sample.php.
total blank webpage situation – i doubt it’s memory since i don’t have more than a couple pages…
Thank you so much!!
Thanks! I had to use 128M, but it works like a charm!
Jeff Moyer says
It’s usually easier to get your web host to do this rather then doing it manually, if you screw something up you can make your website worse.
kelvin carter says
which line of code should i past it
Thank you so much my issue is solved .
Thank you so much.
I had to put: 70MB and went back to work.
“First open your wp-config.php which is located in the root WordPress directory. Then add the following line inside the main php tag:”
I really have no idea what to click to find the wp-config.php or the root WordPress Directory. Is it in the Settings? Sorry. I just can’t figure out. Thanks.
WPBeginner Support says
Please take a look at our guide on how to edit wp-config.php file in WordPress.
Ahan Jain says
I can’t find it. Where can I find my we-configure.php file.
In order to locate your wp-config.php file, you will need to access your clientzone of your web host and locate file manager.
In your public_html folder, you will find your wp-config.php file.
Hope this helps you.
Brittany Goldsby says
Thank you so much for this! Me and my office manager was about to pull our hair out because we couldn’t figure out how to increase the memory limit on a website we were working for a client. We actually increased the memory to ‘128M’ because ’64M’ was already there and it worked like a charm. Thanks!
Olufunmilola Soewu says
Thank you sooooo much, I’h highly grateful. Keep up the good work!!