Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

Fix: WordPress Memory Exhausted Error – Increase PHP Memory

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
Fix: WordPress Memory Exhausted Error – Increase PHP Memory

We have transferred numerous client websites, and sometimes a WordPress Memory Exhausted error shows up when activating a new plugin or doing some other task. Usually the error looks like this:

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

We got an email from a user who was facing the same problem, so we decided to do a writeup on it because this is a common problem. The reason why this error shows up is because you exceed your default Memory Limit. There are numerous solutions for it, but in this article we will share the simplest one out of all.

First open your wp-config.php which is located in the root WordPress directory. Then add the following line inside the main php tag:

define('WP_MEMORY_LIMIT', '64M');

We just increased the memory limit to 64M. If you still get the error after this fix, then please contact your host. Most likely, they would have to go in their php.ini file to increase the memory limit for you. If you have other ways of increasing the memory limit, then let us know in the comments below.


Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. Christian says:

    Sweet! Worked perfectly. Thanks!

  2. gopi says:

    front-end is working fine but when open the back-end i tried to access the menu section under appearance but when i clicked on it, it shows the Fatal Error of Memory exhausted.
    The error is

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 72 bytes) in /home/yyyyyy/public_html/yyyyyy.com/wp-includes/meta.php on line 838

    Please help me in this regard.

  3. sandy says:

    I got this error when trying to install wordpress does anybody got in solution.

    Fatal error: Maximum execution time of 30 seconds exceeded in F:\xampp\htdocs\site1\wordpress\wp-admin\includes\misc.php on line 105

    thank you
    sandy

  4. Aldaz says:

    New to word press how can I fix the following, any help is much appreciated.

    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 6785803 bytes) in /home/content/p3pnexwpnas10_data01/69/2702869/html/wp-content/object-cache.php on line 574

  5. Gerhard says:

    Also had the memory limit problem on edit.php for a custom post type. Found out that if the CPT is hierarchical wp loads all posts so if you dont need it to be hierarchical set it to false in the declaration.

    greets gerhard

  6. Lindsay says:

    Worked like a charm! Thanks for the super simple fix!

  7. Dani says:

    Thanks Sabi Hussain, it just fixed my problem. I saw every forum all adressing the same problem, I have 512M allowed with my server, and define in config.php for 128M but it wasn’t working till I saw your comment, best tip ever. It was overwriting what I define in config.php. Thanks a lot!

  8. David says:

    Please how do I locate my Root WordPress Directory. Please explain with images to help me understand better. Thanks

  9. Ashlee says:

    Hi;
    Supposed to be updating today and got the white screen of death. Went into wp-config.php and changed debug status to true which then popped up with this message. I’ve added the suggested code of both 64 and then 128. This is not working and my host says there is nothing they can do? They keep saying that i’m well below my capacity on my hosting account. I’m not sure they completely understand the issue? Is it something in regards to WordPress that they have to change or does it have to do with my memory space on their server.
    I hope this article isn’t too old and you can response quickly.
    – Ashlee

    • WPBeginner Support says:

      May be this article will help: How to fix the WordPress white screen of death.

    • Doug says:

      Hi Ashlee,

      If you have already changed your wp-includes/default-constants.php file, it could be the server. If you have access to WHM or a developer does who can change settings like max file size for upload.
      For example, if you are having issues with uploading files to WordPress because of their size this can be changed in WHM under Service Configuration > PHP Configuration Editor. You would want to change the upload_max_filesize field from 2M (default) to whatever file size you need.

  10. Kenold Beauplan says:

    128M worked for me.
    Thanks

  11. lootoffers says:

    Fatal error: Cannot redeclare win_is_writable() (previously declared in /home/u805727311/public_html/wp-includes/functions.php:1684) in /home/u805727311/public_html/wp-admin/includes/misc.php on line 557

    Please solutions

  12. Sabir Hussain says:

    so simple
    check this file
    public_html/wp-includes/default-constants.php

    Enjoy

  13. Dong says:

    sorry but the suggested solution is not a fix for me.

    I am using a w3 cache plugin but it was not the culprit.
    I’ve increased memory in php.ini and wp-config.php to 512MB and I still get the Fatal error.

    the workaround was to stop non-important plugin and so far the site is OK (temporarily)

  14. Victoria Miller says:

    Thanks SO much!

    I had created a child theme (my first) and couldn’t understand why just trying to Customize the Appearance in dashboard would cause a Server error. This fix define(‘WP_MEMORY_LIMIT’, ‘128M’); did the trick!!!!

  15. Alinn says:

    Thanks a lot :)

  16. mrunmay phanse says:

    Hey it worked awesome for me…… and thanks to that person who added 128m in comment… i used that tag and it worked =D thanks

  17. Kim says:

    Hi Everyone – Is there a fix for this exact same problem, except instead of “/wp-includes/plugin.php” at the end of the error it’s ” /file.php” ?
    I’m still getting the error and I”m unable to update anything on my site. Thanks so much!

  18. Kassiah says:

    Thanks for this great tip! Worked like a charm :)

  19. Saskia says:

    I have a white screen and cannot open the items in the wordpress directory (only SEO and guestbook). How to increase the memory?

  20. Alex says:

    Hi guys,

    This method can be use to fix the “508 Resource Limited Reached” Problem?

    Thank You

  21. Pete Trenery says:

    Thanks for the great tip – worked a treat.
    Unfortunately all we got after an initial upgrade to WordPress was the WSOD when attempting to login and edit our website.
    Your steps were clear and solved our issue – now able to access via admin login again.

  22. Henry says:

    its great thanks , it worked after increase the memory limit up to 128mb

    define(‘WP_MEMORY_LIMIT’, ‘128M’);

  23. Abdul Qayoum says:

    I installed a wordpress template and then demo content. After that i tried to access the menu section under appearance but when i clicked on it, it shows the Fatal Error of Memory exhausted.
    The error is

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 28593220 bytes) in /home/xxxx/public_html/xxxxxx.com/wp-admin/includes/nav-menu.php on line 1198

    Please help me in this regard.

  24. Anriëtte says:

    Had a strong suspicion this won’t work for my host, but it did, thanks! :)

  25. Noel Cammack says:

    Thanks for the help WPBeginner! You guys rock!

  26. Phil says:

    Perfect

    added
    128mb to remove error as short term solution
    contacted hosting to see if there needs to be a longer term answer also getting php versions updated as well

    added on top line after php tag
    /** Memory Limit */
    define(‘WP_MEMORY_LIMIT’, ‘128M’);

  27. tegori.org says:

    brilliant! thanks for this. I had to increase the limit to 256M, but it worked like a charm.

  28. Kasra Khosravi says:

    Thanks for the great article. I encountered this problem and I used a setting in “All in One SEO Pack” to increase the memory limit.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.