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

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

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.

Fix: WordPress Memory Exhausted Error – Increase PHP Memory

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 a certain amount of memory to efficiently run multiple applications at the same time. Server administrators 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.

How to Increase the PHP Memory Limit in WordPress

There are several ways to increase the PHP memory limit. One is to edit the wp-config.php file, another is to tweak the .htaccess file, and the last method is to check the php.ini file.

Let’s go through each one:

Editing the wp-config.php File

First, you need to edit the wp-config.php file on your WordPress site. It is one of the core WordPress files located in your WordPress site’s 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.

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.

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.

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.

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

464 CommentsLeave a Reply

  1. Syed Balkhi says

    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. Chintan Dave says

    define( ‘WP_MEMORY_LIMIT’, ‘256M’ ); worked all time. Thank a lot for the solution.

  3. mohammed says

    you guys are amazing you solved most of the issues i encounter since started working with WordPress.

  4. Haley McCalister says

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 22 bytes) in /home/nels1max/public_html/ngifts/wp-includes/class-wp-hook.php on line 286

    I’ve tried to expand my limit but it didn’t work. When I refresh the page, it changes what’s after “/wp-includes/” and the line number, but none of those files have a place to expand the size. Any tips?

    • Jordan Casey says

      Try increasing it to 512M. There still isn’t enough memory for whatever theme you’re running. Good luck! P.S. make sure that you have more than 512M of memory. Ask your hosting provider.

  5. Ian says

    It works! Thanks for the suggestion. But I have a question. I find another article said that changes WP_MEMORY_LIMIT in default-constants.php. Is there any different between this two methods?

      • WPBeginner Support says

        The constants file is for settings that don’t change, editing the config file is where you would make changes that can be reverted later when you are no longer receiving the error.

        Admin

  6. Jane says

    I looked everywhere for a solution and even called the host searching for an answer. Fixed it PERFECTLY! Thanks so very much!

  7. kartik says

    Dear All,

    we are getting this error
    let me know the solution on it?

    Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 8192 bytes) in /home/f036v20tz3th/public_html/wp-includes/functions.php on line 5276

    Regards
    KARTIK

  8. Jaime says

    Thanks so much guys for this article! What is the diference from changing wp_memory_limit (wp-config.php) and memory_limit (php.ini)??? Are the same??
    This memory limit is for individual sessions or entire wordpress site?? I ask because if i had 200 visitors in minutes.. i have to go damn higher with this number?? Or try to keep it low??? Hope you can help me with this!

  9. Jeremy says

    Thank you guys so much for this! I spent the last couple hours trying to figure this out.

    Thanks again!

  10. Ujenk says

    When I changed with 512 M it was failed then I put it define( ‘WP_MEMORY_LIMIT’, ‘2000M’ );
    And it works well.
    /* That’s all, stop editing! Happy blogging. */ :-)

  11. Joshua says

    if that code doesn’t work, rephrase it to

    //increase WP Memory Limit
    define(‘WP_MEMORY_LIMIT’, ‘256M’);

    • suraj says

      worked like a charm and loads faster .. but sure would like to knw the root cause and fix the issue there

    • suraj says

      you can change but it maxed out the memory and gave frequent errors of the same, editing posts on wordpress.com also had errors and tags and categories did not populate there.
      in WP it seems to work but it lagged considerably.
      If you have more memory allocated then you can do it. I am gonna do half of memory allocated by hosting. check cpanel for that.

  12. Dee says

    Thank you so much! I’ve been waiting for my developer to respond in order to fix it when I could have just done it myself! So much time wasted, thank you for publishing this!!

  13. Krista says

    You ROCK! Easy to follow and it worked! I am web-illiterate and was able to fix it in one go. THANK YOU!

  14. Sue Hanson says

    Thanks a lot for this article. It really helped me out. I was able to fix this problem and get onto building my site.

  15. Morgan Leahy says

    Before doing any of this…be sure to check your root install directory. I had a blank ‘index.htm’ file that was left by my hosting service, and I completely overlooked it.

  16. Jill says

    Thank you so much for posting this tutorial! It fixed my website so I could start breathing again!

  17. Bharat M says

    You are rocking men…

    Every time I got an problem, I got it solution from here…

    Thanks for the awesome article.

  18. Karen Gusler says

    Thank you!!!! This was a Godsend!!! While trying to troubleshoot why some emails are not being sent via our online form, I installed a plugin and it caused this error. My web site is back up and running!!!! Thank you again!

  19. Jason Didner says

    That fixed a number of problems! Being able to change themes; being able to save my widgets – great tip! Spent a lot of time looking for this solution.

  20. aisha says

    this doesn’t resolve my issue :( plz now tell me what I can do ?
    still error is there

    Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4114136611 bytes) in C:\xampp\…\wp-includes\functions.php on line 5163

    • Joel says

      I get this error quite often. And I am not sure why.

      It comes from the function wp_is_stream(). I’m not sure where this is being used that is causing the error.

      A bit of investigation showed that if you comment out wp_head() in your header.php file that solves the issue. More specifically, it is something hooked onto the ‘wp_head’ action, and I think one of the filters with priority of 10. Unfortunately, after getting this far, the error magically fixed itself and went away, so I wasn’t able to track down the exact function. Also, wp_is_stream() was only used in 3 or 4 places, so maybe you could find the culprit easier just by checking the usages of that function.

  21. Brandon J says

    This was amazing. I was skeptical at first since this was my first time ever doing something like this. I finally just went for it and it worked. Thank you so much.

Leave a Reply to john Cancel 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.