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.

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

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

    Thanks for this article, we’ve been having this problem too.

    Which setting takes priority?
    In WHM (MultiPHP INI Editor), memory_limit is set to 32M.
    In wp-config.php WP_MEMORY_LIMIT is set to 96M.

  3. arjun says

    but what exactly is this wordpress memory limit, like how much amount of RAM should wp use on the server? can anyone please share about what this thing is?

    thanks

    • WPBeginner Support says

      The memory limit tells WordPress how large requests/files can be for individual tasks, this is not for your site’s RAM and your RAM usage would be determined by what is on your site.

      Admin

  4. fazan says

    thanks you wpbeginner
    you solve my problom
    but i have vps , can i increes more memory limit
    please reply

    • WPBeginner Support says

      You would need to reach out to your hosting provider for what is available to you

      Admin

  5. Ananth Gurunathan says

    Thanks for the post. It really worked out for me for my problem which was a big head ache for last 5days. Thanks a lot.

  6. Peter says

    There needs to be a way to figure out these memory issues without taking the entire site offline or risking breaking the configuration by disabling essential components. Furthermore, the errors are occurring even when the memory limit is set to the maximum physical memory on the server (32GB) and while they are occurring there is no actual spike in memory usage (system utilities are reporting no increase in actual physical memory use.

  7. Peter says

    Useless when the issue does not depend on actual required memory – in my case it keeps giving the error for random plugins no matter how much memory I specify (up to 32GB). Would be nice to know an actual troubleshooting method to see what is using the memory.

  8. Wim Hoogenraad says

    I wish I known that earlier. Now | lost a lot of traffic for my site.
    Hopefully it is fixed now!

  9. Mara says

    It works, thank you <3

    The error was:
    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 491520 bytes) in…

  10. EAT (my actual initials) says

    Thank you so, so, so, sooooooooooo, so much! I guess as I add more posts to the database it requires more memory to operate. Various things were breaking with this internal error over the course of a couple of years, but since I could still make new posts I just said to myself, “meh, carry on.”

    Then I could no longer post! Panic! Everybody PANIC!!!

    I enabled debug mode. I got my debug report. I saw the memory exhausted reported. Then I found this page and gave it a try, thinking, “This probably won’t work. I’ve made too many changes to the theme and some of the plugins to work the way I want. Something somewhere got MuNgEd.

    Nope. Not at all. This one line of code solved it and got be back up and RUNNING!!!! Yay for me!!!! YAY FOR YOU!!!!

  11. Mykola says

    And if you have same problem in admin page you can also try

    define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ );

    Administration tasks require much memory than usual operation. When in the administration area, the memory can be increased or decreased from the WP_MEMORY_LIMIT by defining WP_MAX_MEMORY_LIMIT.

    WP_MAX_MEMORY_LIMIT sets the maximum just on admin pages. It’s a terrible naming scheme but it dates back to WordPress 2.5 and nobody dares change it now

  12. Kerry Rixon says

    Thank you Thank you Thank you!
    A novice fixed this problem with your help! Thanks again

  13. Laura Mailleux says

    I have tried this, and now my entire admin panel and website are down, all blocked by that 500 error…. I cannot access anything anymore, and therefore can’t use the File Manager again to remove the change. I’m completely lost, any chance you can help me?

    • WPBeginner Support says

      Hi Laura,

      If you have access to cPanel dashboard then you can undo the changes from the file manager section there. Alternately, you can contact your hosting provider to help you fix this.

      Admin

  14. prashant says

    i have to use wpml plugin issue is english language text editor working properly but when i text german or spanish language (secndery languages ) text editor cant showing on secndery languages text editor so ghow to fix that problem

  15. Jose says

    I contacted my hosting company and requested them to increase my PHP memory, this resolved the issue.

  16. Jonathan says

    Help! i have this problem :(

    Allowed memory size of 268435456 bytes exhausted (tried to allocate 10489856 bytes)

  17. Majid Korm says

    Thank you very much
    My issues got solved completely based on your detailed information and help.
    many many thanks
    Majid

  18. Jonny says

    I’m not as good at this stuff as I need to be, so I’m still struggling with this.

    I open the config.php file and there is a part that says:
    define( ‘WP_MEMORY_LIMIT’, ‘256M’ );

    only it already says:
    define(‘WP_MEMORY_LIMIT’, ‘1024M’);

    I’ve changed that to 2048 and 4096 with no change.

    But there is no ‘That’s all, stop editing! Happy blogging.’

    after the
    define(‘WP_MEMORY_LIMIT’, ‘1024M’);
    it says
    define(‘WP_DEBUG’, false);

    then
    # That’s It. Pencils down

    It does say ‘That’s all, stop editing! Happy blogging.’ in the Sample config.php but not in the actual one.

    Any advice?

Leave a Reply to Chad McCullough 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.