How To Increase Memory Limit In WordPress: A Complete Technical Guide
Experiencing a sudden white screen or receiving a message stating "Fatal error: Allowed memory size of bytes exhausted" is one of the most frustrating challenges a site administrator can encounter. WordPress is built on PHP, a server-side programming language that requires dedicated server memory to execute scripts, process database queries, and run active plugins. When your site demands more memory than the host or core application has allocated, processes abruptly terminate, resulting in execution failures.
Understanding how server memory allocation works is fundamental to maintaining a fast, stable, and secure website. Every plugin, theme file, database query, and custom script consumes a portion of your allocated RAM. While the default core memory settings are often adequate for lightweight blogs, modern dynamic websites relying on page builders, custom web apps, or e-commerce features inevitably require significantly higher memory thresholds to function smoothly.
Increasing your WordPress memory limit is a straightforward fix once you know which configuration file to alter. Depending on your hosting environment, server architecture, and file permissions, you can modify server limits through several primary vectors: the site configuration file, the server-level control panel, or Apache/Nginx environment settings.
Understanding WordPress Memory Limits and Fatal Errors
PHP memory limits serve as a protective boundary for web servers. Without a designated cap, a corrupted plugin script, an infinite loop, or a poorly optimized database query could consume all available physical memory on the host server. This exhaustion would crash not only your site, but potentially every other site hosted on that shared environment. To prevent this scenario, PHP enforces a maximum memory allocation ceiling per script.
By default, WordPress attempts to set its own PHP memory limit to 40MB for single-site installations and 64MB for multisite networks. However, modern page builders like Elementor or Divi, alongside feature-rich plugins such as WooCommerce, often require a minimum of 128MB to 256MB to process backend operations. When the memory consumption exceeds the enforced limit, PHP halts execution immediately and prints the infamous fatal memory exhausted error on the screen or inside your error logs.
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 122880 bytes) in /home/user/public_html/wp-includes/plugin.php on line 140
The error message displays exact figures detailing the conflict. The total byte limit in the error string reveals your current cap—for example, 67,108,864 bytes equals precisely 64 megabytes. The error also identifies the exact file and line number where the script ran out of processing headroom. Increasing this ceiling resolves the issue immediately, provided your web host permits higher allocation limits on your hosting package.
How to Check Your Current Memory Allocation
Before modifying system configuration files, you should verify the existing memory limits assigned to your WordPress environment. WordPress features built-in diagnostics that allow site administrators to inspect server-level parameters without installing additional monitoring utilities.
Navigate to your WordPress dashboard, hover over Tools, and select Site Health. Click on the Info tab at the top of the interface, then expand the WordPress Constants and Server sections. The WordPress Constants dropdown displays the specific limit set within your site files (WP_MEMORY_LIMIT), while the Server dropdown reveals the master limit set by your hosting environment (PHP memory limit).
Alternatively, if you run WooCommerce, navigate to WooCommerce > Status. The system status report explicitly lists the PHP Memory Limit in bold, highlighting values in red if they fall below the recommended minimum threshold of 128MB. Identifying both values helps determine whether your constraint stems from internal WordPress configuration constants or underlying server configuration files.
Fix the WordPress memory exhausted error increasing the PHP memory ...
Step-by-Step Methods to Increase the PHP Memory Limit
Method 1: Editing the wp-config.php File
The most direct way to increase the memory limit in WordPress is by editing the wp-config.php file, which resides in the root directory of your website installation. This file contains primary system configurations and base database parameters.
- Connect to your web server using an FTP client (such as FileZilla) or through your host's cPanel File Manager.
- Locate the
wp-config.phpfile in the main directory (usuallypublic_htmlorwww). - Create a backup copy of the
wp-config.phpfile on your local machine before making any modifications. - Open the file in a code or text editor and scroll near the bottom until you locate the line that says:
/* That's all, stop editing! Happy publishing. */. - Directly above that line, insert the following code snippet:
define('WP_MEMORY_LIMIT', '256M');
If you perform intensive operations inside the administrative dashboard—such as bulk product updates or running heavy database migrations—you can also define a separate limit specifically for backend administrative operations by adding this line directly underneath:
define('WP_MAX_MEMORY_LIMIT', '512M');
Save the file and upload it back to your server. Refresh your site dashboard and inspect the Site Health interface to confirm that the changes took effect.
Method 2: Editing the PHP.ini File
If editing wp-config.php does not yield results, your hosting server is likely overriding application-level directives with master environment settings. In such cases, you must adjust your server's php.ini file.
The php.ini file controls global settings for PHP execution on your server. If you utilize VPS, dedicated hosting, or shared hosting environments running cPanel, you can edit or create this file in your site's root folder.
- Open your File Manager or FTP client and navigate to the root directory.
- Search for an existing
php.inifile. If no such file exists, create a new plain text file namedphp.ini. - Open the file and locate or add the line controlling memory limit allocation:
memory_limit = 256M
- Save and re-upload the file to the root server folder.
If your host uses cPanel, you can often bypass manual file editing by locating the MultiPHP INI Editor tool under the Software section. Select your home directory or domain name from the dropdown menu, locate the memory_limit row, enter 256M into the field, and click Apply.
Method 3: Editing the .htaccess File
For websites hosted on Apache server environments, configuration options can often be modified through the .htaccess file. This hidden file controls server rules, redirects, and runtime directive overrides.
- Access your site root folder via FTP or File Manager. Ensure that your FTP software is configured to show hidden files (files starting with a dot).
- Locate and back up your
.htaccessfile. - Open
.htaccessand locate the# BEGIN WordPressblock. - Add the following line at the top or bottom of the file, outside of the standard WordPress rewrite block:
php_value memory_limit 256M
Save the file and check your website. If your server encounters a "500 Internal Server Error" immediately after adding this line, your web host does not allow runtime PHP changes via .htaccess. Simply delete the line, re-save the file, and attempt an alternative method.
Method 4: Modifying the .user.ini File (Nginx / LiteSpeed)
On modern hosting platforms running Nginx or LiteSpeed web servers, standard .htaccess directives might not function. Instead, these environments use a localized configuration file called .user.ini.
- Check your root directory for an existing
.user.inifile. - If it does not exist, create a new file named
.user.ini. - Add the following directive inside the file:
memory_limit = 256M
- Save the file. Note that unlike Apache directives, changes in
.user.inican take up to 5 minutes to fully propagate across the environment due to server-side caching mechanisms.
Comparison of Memory Configuration Methods
Selecting the correct method depends on your hosting architecture, user permissions, and server operating system. The following matrix compares each available approach.
| Method | File Path | Access Level Needed | Risk Level | Propagation Time |
|---|---|---|---|---|
| wp-config.php | /public_html/wp-config.php |
FTP / File Manager | Low | Instant |
| php.ini | /public_html/php.ini |
cPanel / SSH / FTP | Medium | Instant |
| .htaccess | /public_html/.htaccess |
FTP / File Manager | Medium (500 Error Risk) | Instant |
| .user.ini | /public_html/.user.ini |
FTP / File Manager | Low | 1 to 5 Minutes |
| Host Support | Hosting Dashboard / Ticket | Customer Account | None | Varies by Host |
Pros and Cons of Increasing PHP Memory Allocation
Increasing system resources provides immediate relief for resource-intensive applications, but it comes with operational trade-offs that site owners must evaluate carefully.
Advantages
- Prevents Unexpected Downtime: Eliminates fatal script termination during critical database transactions, theme customizations, or plugin updates.
- Enables Complex Features: Allows usage of enterprise-grade tools, page builders, search indexers, and real-time inventory management systems.
- Improves Administrative Performance: Speeds up backend processing times, script execution, and complex data import/export routines.
Disadvantages
- Masks Poor Code Quality: Raising limits can conceal poorly coded plugins that leak memory rather than fixing the underlying software defect.
- Increases Hardware Resource Usage: Allocating higher RAM thresholds to individual processes limits the total number of concurrent visitors your server can handle simultaneously before running out of system memory.
- Shared Hosting Caps: Web hosts enforce hard limits at the physical hardware level. If you set your configuration higher than your hosting plan allows, your manual edits will simply be ignored.
Troubleshooting Persistent Memory Issues
If you have implemented these edits and your site continues to report a memory exhausted error, consider the following potential root causes:
- Host-Level Allocation Limits: Your hosting package may enforce a hard hardware cap (e.g., 64MB or 128MB max) that overrides local user directives. In this scenario, contact your hosting support team or upgrade your hosting plan.
- Caching Delays: Server-side caching tools like Redis, Memcached, or OPcache may temporarily store old configuration values. Clear all server and site-level caches after applying edits.
- Runaway Plugin Loops: A single plugin might contain a broken script or infinite loop that consumes an infinite amount of memory, regardless of whether your limit is set to 256MB or 2GB. Perform a plugin isolation test by disabling plugins one by one to isolate memory-hogging extensions.
Frequently Asked Questions
What is the recommended memory limit for a standard WordPress website?
For simple blogs or portfolio sites, 128MB is usually sufficient. However, for websites running WooCommerce, page builders, or multiple active plugins, 256MB is the industry-standard recommendation to ensure consistent site performance.
What is the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?
WP_MEMORY_LIMIT controls the memory cap allocated for standard frontend site operations and public-facing user visits. WP_MAX_MEMORY_LIMIT defines the ceiling for administrative processes inside the backend dashboard, such as media uploads, database updates, and plugin installations.
Why did my memory limit remain unchanged after editing wp-config.php?
If modifying wp-config.php yields no change, your web host likely enforces a strict limit at the server environment level inside global PHP settings. You must update your php.ini file or ask your host to increase the allocation manually.
Can setting the memory limit too high slow down my site?
Allocating excessive memory to individual PHP tasks does not directly reduce page speed, but it increases total server resource consumption. On shared hosting servers, high memory settings per process reduce the total number of concurrent requests the server can manage before running out of physical RAM.
Is a 512MB memory limit safe for shared hosting environments?
While defining a 512MB limit in your site files is generally safe, most entry-level shared hosting packages hard-cap user limits between 128MB and 256MB. Exceeding those physical boundaries usually requires upgrading to a Managed WordPress hosting service, a Virtual Private Server (VPS), or a dedicated hosting plan.
Optimize Your WordPress Server Architecture Today
Resolving memory exhaustion errors is essential for maintaining a fast, reliable, and secure online presence. By systematically adjusting system directives within your wp-config.php, php.ini, or .htaccess files, you ensure your plugins and custom scripts have the physical headroom necessary to execute without interruption.
If manual updates fail to resolve script failures or your site frequently hits server thresholds, your platform may have outgrown its current hosting environment. Contact your hosting provider to discuss physical server limits, or audit your installed plugins to streamline resource usage across your entire site architecture.
