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. With your permission, I’d like to add a note for users to the article:
    Please note that htaccess is a hidden file. First, check if it exists. In case you couldn’t find the .htaccess file in your hosting, you can create one using text editor programs like Notepad. Simply create a file named htaccess. Alternatively, in the public_html directory, click on “New File” and create a file with the same name.

  2. I have encountered this issue multiple times, and it seems to be one of the most common problems in the WordPress domain. Each time, I either contacted the hosting support or edited the htaccess file to resolve the issue. The htaccess file appears to be like a magic solution, and whenever an issue arises, it can be quickly reviewed and fixed.

  3. I used to encounter some errors like this on my websites but I didn’t know what to do. Something when I tried to solve it, I just uninstall the step and re-install it back and upload the backup.
    I noticed the problems still persist, when I enable wp debug mode, t then see the exact errors and the it’s source.
    I later find this guide and implented it and it works.

    Thanks.

  4. AFter updating my .htaccess it gives me this error:

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

  5. Regarding the .htaccess file, be cautious. Many shared web hosting providers may have directives for increasing the memory limit disabled. Such a directive in the .htaccess file can cause a 500 error on the website, requiring its removal or commenting out. Be careful with this. Sometimes, simply increasing the memory limit may not solve the problem but rather delay it, like a painkiller. The pain might subside, but it doesn’t mean the cause has been resolved. Therefore, while increasing the memory limit might seem like a solution, it’s also important to check what is consuming the memory. Sometimes, people increase the memory limit from 512 MB to 1024 MB without considering whether it’s necessary, and whether the memory limit isn’t masking an underlying issue on the website.

    • Thank you for sharing your feedback on the htaccess change. Unless the host has very strict rules in place adding to the htaccess shouldn’t cause an error it is more likely to not work and would require you reach out to the host to request an override.

      Admin

      • In the Czech Republic, practically 90% of web hosting providers prohibit manipulating PHP limits. The simple reason for this is that it’s a source of revenue for them. The limits are usually fixed, and if you want a higher limit, you have to switch to a more expensive plan. Therefore, after reading many of your posts, I also started considering foreign web hosting providers for new websites, such as HostGator or DigitalOcean. Abroad, such issues with limits typically don’t exist as they do here.

  6. It doesn’t solve my problem still shows an error after placing the code “define( ‘WP_MEMORY_LIMIT’, ‘256M’ );” and I also change the size of Memory_limit of Php.ini file

    • As we state in the article, if our code does not work, there is a good chance your hosting provider is overriding the memory limit and you would need to reach out to your host to fix the error.

      Admin

  7. It doesn’t solve my problem still shows an error after placing the code “define( ‘WP_MEMORY_LIMIT’, ‘256M’ );” & this is my front-end page showing

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 8192 bytes) in /home/X/wp-includes/class-wp-dependencies.php on line 260

    • If the code does not work for you, we recommend reaching out to your hosting provider as they may have a limit set on their end that could be the root of the issue.

      Admin

  8. Thank you, this was helpful! All problem has been solved by carefully following this step-by-step instructions. Keep up the good work :)

  9. Hi,

    Thank you for this awesome website. I got this in the error log after adding this code.
    [26-Apr-2022 02:45:31 UTC] PHP Warning: Use of undefined constant ‘WP_MEMORY_LIMIT’ – assumed ‘‘WP_MEMORY_LIMIT’’ (this will throw an Error in a future version of PHP) in /wp-config.php on line x

    Is this a problem? Should I remove the code?

    • That would only be an error for future versions of PHP. This solution should only be a temporary fix and your hosting provider should be able to assist with the root cause of the issue.

      Admin

  10. Thank you! You folks rock. This solved my problem. WPBeginner is my go-to website for learning new things about WordPress, even though I’m not a beginner.

  11. “Once you are done, you need to save your changes and upload your wp-config.php file back to your server.”

    How again do you upload the file back to your server?

    • You would need to use FTP or your host’s file manager again and there should be the option to upload and replace the file :)

      Admin

  12. The changes are not having effects. We are still with 40MB and the site does not accept the changes. What should I do?

    • As we state at the end of the article, if our recommendations do not work, please reach out to your hosting provider as they may have set a limit that would override what you as a user can set.

      Admin

  13. Really worked.

    I had white screen when I wanted to create a new post on PC browser. But worked on my phone.

    Thanks

  14. Thank you for providing a straight forward solution to an error which occurred when I tried to update the php version from 7.1 to 7.4

  15. Fantastic, thank you soooo much for this, simple straight talk.. excellent.. first problem solved … now got to learn more

    • It can mean the site can take longer to notice issues if some arise but shouldn’t cause a major issue in general.

      Admin

  16. I added the code problem is gone but a text “WP_MEMORY_LIMIT” has appeared in the top corner of logo. So what should I do about that?

    • You would want to ensure you added the code snippet correctly as it is likely showing that code thinking it is text.

      Admin

  17. “First you need to edit the wp-config.php file on your WordPress site. It is located in your WordPress site’s root folder, and you will need to use an FTP client or file manager in your web hosting control panel.”

    Simple! What does that mean? It is gobbledegook to me.

  18. I’m new in WordPress and I’m trying to figure out, for a couple of days, why suddenly I get an error 500 and can’t save my edits. This helped solve my problem. Thank you so much!

  19. This solution is not working for me, my website is hosted at AWS server and I have all the access, I have tried to set memory_limit in php.ini, wp-config and .htaccess. but still getting issue when accessing backend pages.

    • You would want to reach out to the support for your hosting for what other options you have available with AWS

      Admin

  20. Thanks so much! Was so worried when I had this fatal error, but this fix is just a piece of cake! :-)

    • If our recommendations are not working, you would want to reach out to your hosting provider and they should be able to assist

      Admin

  21. Hi, I had the memory exhausted message and I increased the wp memory limit to 12mb and it worked. Then a few days later I had the same error, so I had to increase the wp memory limit to 256mb and the message kept showing. I am currently on 1024mb, which seems excessive for a small website of 4 pages and a blog post of 15,000 words. Any suggestions how to resolve the issue or what might be causing it?

    • You would want to reach out to your hosting provider and they can normally assist in finding the root of the issue for your specific site.

      Admin

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.