Have you ever encountered the “memory size exhausted” message on your website? If yes, then you’ll probably know that this single issue can bring your entire site to a halt.
If you are seeing this message, don’t panic. It’s one of the most common issues WordPress users face – and is completely fixable.
This fatal error simply means that a script on your site (usually from a plugin or theme) required more server memory (RAM) than your web hosting environment was configured to provide.
In this guide, we will walk you through everything you need to know to solve the “memory size exhausted” problem for good.
You’ll learn how to check your current WordPress memory limit and discover proven methods to increase it, whether by editing the wp-config.php file, the .htaccess file, or the master php.ini file.
Let’s get started!
How to Check Your Current PHP Memory Limit in WordPress
Before you can fix a memory exhausted error, you first need to identify your current limit. There are several ways to do this.
1. Using the Site Health Tool in the WordPress Dashboard
The easiest and safest way for any user to check the PHP memory limit is directly within the WordPress dashboard. WordPress has a built-in “Site Health” tool that reports your website’s configuration and server environment.
To access it:
- Navigate to your WordPress admin area and go to Tools > Site Health.
- Click on the “Info” tab at the top of the page, which will reveal a series of expandable sections.
- Click on the “Server” dropdown, and you will see a detailed list of your server’s configuration.
- Look for the “PHP memory limit” entry to see the value configured for your site.

Suggested read: How to Fix WordPress High CPU Usage (10 Instant Solutions)
2. Checking PHP Info or Server Configuration Files
If you want more information or can’t access the WordPress dashboard, you can create a phpinfo file. This method queries the server directly and displays the master PHP configuration.
To do this, you just need to create a new file named info.php in your website’s root directory using an FTP client or a file manager, and place the following single line of code inside it:
<?php phpinfo(); ?>Save the file, then visit yourwebsite.com/info.php in your browser. You will see a detailed page with all PHP settings; search for memory_limit to find the current value.

Note: for security reasons, you must delete the info.php file from your server immediately after you are finished, as it exposes sensitive server configuration details.
Suggested read: How to Fix WordPress Stuck in Maintenance Mode? [100% WORKING]
3. Identifying Memory Limit via Hosting Control Panel (cPanel, RunCloud, etc.)
Most modern hosting environments provide a graphical interface to view and manage server settings. In traditional control panels like cPanel, you might find this information under a “MultiPHP INI Editor” or “Select PHP Version” tool.
On a more powerful platform like RunCloud, this information is even more accessible and transparent. Simply navigate to your Web Application > Settings within the RunCloud dashboard.
Here, you will see your current PHP version and its associated memory limit clearly displayed:

Suggested read: How to Fix WordPress Revisions Not Showing [SOLVED]
How to Fix the WordPress Memory Exhausted Error (7 Proven Methods)
There are several ways to fix the WordPress Memory Exhausted error, ranging from simple configuration file edits to leveraging your hosting control panel. Let’s explore these methods in detail to help you get your WordPress site back on track.
1. Increase PHP Memory Limit via wp-config.php File
This is the standard WordPress method for increasing the memory available to your application. The wp-config.php file contains your site’s base configuration and is located in the root directory of your WordPress installation.
(Before editing, it is recommended that this file be backed up.)
First, you need to open the wp-config.php file either using your FTP client or the RunCloud File Manager. In this file, add the following line of code just before the line that says /* That’s all, stop editing! Happy publishing. */:
define('WP_MEMORY_LIMIT', '256M');If needed, you can change 256 MB to a higher value, like 512 MB. This command instructs WordPress to override the default PHP memory limit for its own processes.

Suggested read: How to Check Linux CPU Usage or Utilization (5 Ways)
2. Edit the .htaccess File to Raise Memory Limit
If editing wp-config.php doesn’t work, it may be because your hosting provider has locked that setting at the server level. In some Apache servers, you can also edit the .htaccess file, which is also located in your site’s root directory. This file controls server configurations for your specific directory.
Again, ensure you have a backup before proceeding. Open the .htaccess file and add the following line at the very end of the file:
php_value memory_limit 256MSave the file and check if the error is resolved.
Suggested read: How to Find the Most Used Disk Space Directories and Files in Linux
3. Modify the php.ini File on Your Server
The php.ini file is the master configuration file for PHP on your server. Modifying this file changes the memory limit for all PHP applications, not just WordPress, which makes it the most powerful method. However, on shared hosting, you typically do not have access to this file, so this method is primarily for users on a VPS or dedicated server where you have root or sudo privileges.
If you have server access, you must first locate the correct php.ini file, as its location varies significantly by Linux distribution and PHP version. For instance, on a server running Ubuntu or Debian with PHP 8.1 and Apache, the path is /etc/php/8.1/apache2/php.ini. If you’re using NGINX with PHP-FPM, the path would instead be /etc/php/8.1/fpm/php.ini. On distributions like CentOS or AlmaLinux, a common location is simply /etc/php.ini.
The most reliable way to find the exact path your web server is using is to check the “Loaded Configuration File” line within a phpinfo() page, as explained above. Once you have located and backed up the correct file, you will find and change the following line:
memory_limit = 256MSuggested read: The 10 Best PHP Frameworks (Complete Guide)
4. Use the Hosting Control Panel or the RunCloud Dashboard to Increase Memory
The safest and most recommended method for novice users is to use the tools provided by your hosting provider or server management panel. These interfaces are designed to prevent the configuration errors that can occur when editing files manually. Most control panels have a section for managing PHP settings where you can select your domain and choose a new memory limit from a dropdown menu.
RunCloud excels at this, and it provides a dedicated and intuitive control for each web application. From your dashboard, go to Web Application > Settings, where you can easily adjust the PHP memory_limit with a simple input field.

After you make the necessary changes, you can save the settings without any need for SSH or FTP.
Suggested read: How to Fix WordPress HTTP Error When Uploading Images (Quick Guide)
5. Deactivate Heavy or Poorly Coded Plugins
Sometimes, the problem isn’t the memory limit itself, but a single plugin consuming an excessive amount of resources. A poorly coded plugin or a feature-heavy one (like a page builder or a complex backup solution) can easily trigger a memory error by creating a memory leak or simply by performing a task that is too resource-intensive for your server’s configuration.
In this case, increasing the memory limit will not solve the issue, and you will need to identify the specific component causing the issue without disrupting your live site.
Instead of resorting to the time-consuming method of deactivating all plugins on your live site, your first step should be to check the server logs. The NGINX error logs, for instance, often contain the exact PHP script path that triggered the fatal error.
Furthermore, a plugin that exhausts memory is frequently a slow-performing one; this is where RunCloud’s built-in slow script monitoring becomes invaluable. It helps you identify scripts that are taking too long to execute and are likely candidates for high memory usage.

Once you have identified a suspect, the safest way to confirm your diagnosis is in a non-production environment. Instead of deactivating plugins on your live site and risking further downtime, use RunCloud’s one-click staging functionality. This creates an identical, isolated copy of your site where you can safely deactivate the suspected plugin and test thoroughly without impacting your visitors. If the error disappears on the staging site, you’ve found your culprit and can proceed with deactivating or replacing it on your live production site.
Suggested read: Everything You Need To Know About the wp-config.php File
6. Optimize Images and Media Files to Reduce Memory Usage
One of the most common reasons for memory exhaustion is uploading large, high-resolution images. When you upload a picture, WordPress doesn’t just store it directly; it uses PHP to process it and create multiple smaller versions (thumbnails). This image processing is a very memory-intensive task, and a large file can easily push PHP past its limit.
To prevent this, always optimize and resize your images before uploading them to WordPress using a tool like Photoshop or an online image compressor. You can also use a WordPress plugin that optimizes images on the fly, but be mindful that the optimization plugin itself will also consume resources. By reducing the initial file size, you significantly decrease the amount of memory needed for processing.
Suggested read: Scaling RAM & CPU Cores – How They Affect WordPress Performance
7. Upgrade Your Hosting Plan for Higher PHP Memory Allocation
If you have tried all the above methods and are still hitting memory limits, especially on a shared hosting plan, it may be time to upgrade. Shared hosting environments place strict, and often low, caps on resources like RAM to ensure stability for all users on the server. No amount of configuration file editing can overcome a hard limit imposed by your provider.
Upgrading to a VPS (Virtual Private Server) gives you dedicated resources and full control over your server environment. With RunCloud managing your VPS, you can easily set your PHP memory limit to 512 MB, 1GB, or whatever your applications require.
Wrapping Up: Best Practices to Prevent the WordPress Memory Exhaustion Error
In this post, we have shown you not only how to fix the WordPress memory exhausted error but also how to build a resilient and high-performing website. After fixing the error, you can optimize your site by implementing a couple of best practices to prevent this in the future.
One of the most powerful preventative measures is to reduce your server’s overall workload. Every time a visitor loads a page on your site, WordPress executes PHP scripts and queries the database, all of which consume memory. Caching drastically reduces this workload by storing and serving a static HTML version of your page, bypassing the need for most PHP executions.
With RunCloud, you can enable a highly optimized server-level solution like RunCache (NGINX FastCGI cache) with a single click. This immediately lowers your server’s memory and CPU usage and makes your site significantly faster.
This is just one example of how RunCloud transforms server management from a reactive chore into a proactive strategy.
Sign up for RunCloud today and experience a faster, more stable WordPress site.
FAQs on WordPress Memory Exhausted Error
How do I increase PHP memory in WordPress?
The most effective method is to edit your wp-config.php file by adding the line define('WP_MEMORY_LIMIT', '256M'); just before the “That’s all, stop editing!” comment. If this doesn’t work, your host may be overriding it, so you can try setting the memory_limit value in your .htaccess or php.ini file.
What causes memory limit errors in WordPress?
Memory limit errors occur when a WordPress script, typically from a plugin or theme, requires more RAM than the server has allocated for PHP. This exhaustion is often triggered by resource-intensive functions, poorly coded components, or complex database queries that push the process beyond its allowed memory threshold.
Why does my site crash when uploading images?
Image uploads are a memory-intensive process because WordPress must not only receive the file but also process it to create multiple smaller sizes (thumbnails). If the original image is very large or your PHP memory limit is low, this process can easily exceed the allocated memory and trigger a fatal error.
How do I find my current PHP memory limit?
The easiest way is to navigate to “Tools > Site Health” in your WordPress dashboard, click the “Info” tab, and expand the “Server” section. Alternatively, a more direct server-level approach is to create a file named info.php in your root directory containing <?php phpinfo(); ?> to view the master memory_limit value.
Can plugins cause memory exhaustion?
Yes, plugins are the most frequent cause of memory exhaustion errors in WordPress. A single poorly coded plugin or too many plugins running complex operations simultaneously (like page builders, backup solutions, or security scanners) can quickly consume all available memory.
What is the ideal PHP memory limit for WordPress?
A baseline of 128M is a good starting point for a modern website, but 256M is a safer and more common recommendation. For robust sites, especially those running e-commerce platforms like WooCommerce or numerous plugins, setting the limit to 512 MB is often ideal for preventing memory-related errors.
How do I fix fatal errors in WordPress?
First, enable WP_DEBUG in your wp-config.php file to see a more detailed error message that often points to the culprit plugin or theme. If it’s a memory issue, increase the PHP memory limit; otherwise, the standard troubleshooting procedure is to deactivate all plugins and switch to a default theme to isolate the problem.
Does changing themes affect memory usage?
Absolutely, themes can have a significant impact on memory usage, as modern themes often bundle complex features and functionality. A lightweight, well-optimized theme will consume far less memory than a large, multipurpose theme packed with page builders, sliders, and extensive integrations.






