Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Fix: WordPress Memory Exhausted Error – Increase PHP Memory

Do you see 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.

Fix: WordPress Memory Exhausted Error – Increase PHP Memory

What Is the WordPress Memory Exhausted Error?

The WordPress memory exhausted error is a message you might see if your website is struggling to perform tasks.

WordPress is built using PHP, a server-side programming language that needs memory to run.

Just like any other computer, web servers have a limited amount of memory to run multiple applications at the same time. WordPress hosting providers allocate specific memory sizes 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

Memory exhausted error displayed on a WordPress site

Your WordPress site may be exhausting its server memory if it has:

  • A lot of images, videos, and other types of media
  • Plenty of unused WordPress plugins
  • Outgrown its hosting plan resources

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.

You can use the quick links below to navigate through the tutorial:

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.

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 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', '256M' );

This code tells WordPress to increase the PHP memory limit to 256MB.

For more details, 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 256M

Similar to the previous code, it will tell WordPress to increase the PHP memory limit to 256MB.p

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, 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.

You can read our guide on how to properly ask for WordPress support for more information.

Option 4: Upgrading Your WordPress Hosting

If you’re constantly encountering 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 to a plan with a higher memory allocation can be a permanent solution.

Consider upgrading your WordPress hosting if:

  • You’ve tried the previous solutions and 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:

Bluehost offer for WPBeginner readers

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.

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 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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

465 CommentsLeave a Reply

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Nilanjan Roy

    That fixed my issue too :) Thanks a lot :)

  3. Alasdair MacNeill

    This fixed my issue – thank you for the advice!

  4. Momodu Oladapo Ibraheem

    Thanks works for me!!! Your site has been a source of refuge always for WP

  5. Joshua

    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?

    Many thanks.

    • WPBeginner Support

      Hey Joshua,

      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.

      Admin

  6. Aaron Silva

    Thanks a lot! it worked!!!!! :) :)

  7. Olayika Olumayokun

    Thanks so much for this type of post, really helped.

  8. Waqas Gulraiz

    Worked! thanks :)

  9. Nicole

    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!

  10. Laercio

    I had to edit php.ini and increase memory_limit from 64M to 256. It worked fine!

    • Daniel

      Updating the php.ini file from 32M to 64M worked for me! Thanks!

  11. Roger

    Thank you, this helped me a lot!

  12. Cole Ryan

    Simple. Effective. Thank you.

  13. Jos Schuurmans

    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?

    Cheers,
    Jos

  14. Chris

    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.

  15. Nathalie

    God bless you guys!!!

  16. Luiz

    Thank you, this article helped me a lot!

  17. Arjuna

    Hi!
    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

  18. Kay

    Hi there,

    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!

  19. Fazzy

    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.

  20. anand

    its working , thanks

  21. Avinash

    Thank you so much :)

  22. Jake

    Thank you so much! Helped like a charm!

  23. shibby

    What a legend!! Been frustrated by this all weekend and now sorted

  24. Tom

    Thank you!!!!!

  25. Dee

    Thanks a bunch!

  26. Nitin Yadav

    Allowed memory size of 67108864 bytes exhausted (tried to allocate 229376 bytes)
    My Problem is this

  27. Kendra

    Thank you! It’s been a while since I ran into this problem and forgot how to fix it! :D

  28. lauren

    this saved me hours of struggle, thank you so much!

  29. kandra

    Nice one, i wonder I could increase the memory of instant wp aplication in order to successfully migrate my blog in blogger to wordpress.

  30. Mitra

    OMG! Thanks so much for this article.

  31. goatlady

    Thank you so much.. works perfectly..

  32. Laxmanrao

    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

  33. lexspark daville

    increasing the memory limit worked for me….thanks a lot

  34. Vikash Kumar

    Thanku you soo much… i was facing this issue and your post saved my day

  35. Neha Srivastava

    Hi,
    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.

  36. Sue P.

    Thank you, it worked!

  37. Taim

    I increased the limit to 128M but the same problem. Then I increased it to 256M and now its working fine.

  38. sheila

    Thank you! Worked like a charm!

  39. Amit Sharma

    Now its working. Thanks a lot for sharing such a great information.

  40. akshay

    work like charm thank you very much…..

  41. Emily

    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

  42. ginger

    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…

  43. maría

    Thank you so much!!

  44. Steven

    Thanks! I had to use 128M, but it works like a charm!

  45. Jeff Moyer

    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.

  46. kelvin carter

    which line of code should i past it

  47. khasim

    Thank you so much my issue is solved . :)

  48. AmigoGeek

    Thank you so much.

    I had to put: 70MB and went back to work.

    :-)

  49. Blogger

    “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? :D Sorry. I just can’t figure out. :) Thanks.

      • Ahan Jain

        I can’t find it. Where can I find my we-configure.php file.

    • Francois

      Hi,

      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.

  50. Brittany Goldsby

    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!

  51. Olufunmilola Soewu

    Thank you sooooo much, I’h highly grateful. Keep up the good work!!
    Thanks.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.