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. RetroMike says:

    Nice one! Instafix :)

    (well… after opening loads of other tabs and not doing it for 10 minutes…)

  2. Shubham Singh says:

    I’m getting this problem..please help me wp beginner..

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 786432 bytes) in /home/mom14isgod/public_html/wp-includes/SimplePie/Item.php on line 2736

  3. JK says:

    Howdy,

    Where exactly should I place this in the wp-config.php file? Under what? Before what?

    Please help – I think this issue has made me a bit more insane!

    Ta
    JK

    • WPBeginner Support says:

      You should paste this code just before the line “/* That’s all, stop editing! Happy blogging. */”

  4. sajid says:

    sir i am trying to upload images in wordpress directory but after add images in wordpress page its not showing and also showing 404 error can you tell me the reason ?

  5. Sarah says:

    Problem: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) ..

    Solve: I sovle It

    step 1. Login Cpanel

    step 2. Go to Web root (public_html/www) click GO

    step 3 find php.ini OR .htaccess file

    edit php.ini OR .htaccess file

    max_execution_time = 30
    max_input_time = 60
    memory_limit = 128M

    TO

    max_execution_time = 30
    max_input_time = 60

    memory_limit = 512M

    Then solve my error.

    If any body face problem please contact me at

    • Shah Nasir says:

      Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 18 bytes) in /home/unlockingportal/public_html/wp-content/plugins/Ultimate_VC_Addons/modules/Ultimate_List_Icon.php on line 147
      plz fix this i tried so many times with ur instructions but still i face same problem

    • Smith says:

      I solve my problem flow your note but one more problem if you provided your contact i will helpfulness

    • faisal says:

      hi. i have facing some issue with word press online. i worked locally on my machine then upload online, everything working fine, but my theme not editable online.

      HTTP ERROR 500

    • john says:

      hello mate im having this problem with my wordpress can you help i already tried that what you post. best regards

    • Gabriela says:

      I can’t find my .htaccess or php.ini file in CPanel :( Help!

    • Alpesh Desai says:

      Bro I searched this but not found
      php.in

      and Found
      .htaccess

      but not showing memory limit please email me

  6. Jhasketan Garud says:

    Thanks a lot . It just saved me from a 503 error as well.

  7. aqib says:

    i am getting this eror when i publishig new post
    ”Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 77 bytes) in /home/veri85fa/public_html/wp-content/plugins/wordpress-23-related-posts-plugin/recommendations.php on line 57
    plz give sloution to fix this

  8. Ahmed says:

    i don’t know how to thank you, i spent the whole day tryig to figure out what’s the problem with my site until i found this simple “memory increase” solution.

    THANK YOU

  9. Erick Ferrari says:

    Thanks WP Beginner!

    It worked great with my website.

    As a suggestion: This happens due to the over usage of memory.

    In my case I had too many Plugins installed in my website.

    I deleted the unused plugins as well and the memory problem was solved easily.

    If you are planing for a robust website it is better to extend the memory on the config.php as you start to build the website.

    Thanks

    Erick

  10. Mos says:

    Hello,
    How do identify the main php tag?
    Thanks!

  11. Christian says:

    Sweet! Worked perfectly. Thanks!

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

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

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

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

  16. Lindsay says:

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

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

  18. David says:

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

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

  20. Kenold Beauplan says:

    128M worked for me.
    Thanks

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

  22. Sabir Hussain says:

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

    Enjoy

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

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

  25. Alinn says:

    Thanks a lot :)

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

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

  28. Kassiah says:

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

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

  30. Alex says:

    Hi guys,

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

    Thank You

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

  32. Henry says:

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

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

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

  34. Anriëtte says:

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

  35. Noel Cammack says:

    Thanks for the help WPBeginner! You guys rock!

  36. 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’);

  37. tegori.org says:

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

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