The error message "Fatal error: Allowed memory size of XXXXX bytes exhausted" is one of the most common problems WordPress site owners encounter. It means PHP tried to use more RAM than the server allows for a single process. This guide covers every method to diagnose the real memory limit, raise it correctly, and verify the fix — whether you are on shared hosting with DirectAdmin or a more restricted environment.
What Is PHP Memory Limit and Why Does It Matter?
PHP Memory Limit (memory_limit) is the maximum amount of RAM that a single PHP process can consume per request. When WordPress loads a page, runs a cron job, processes a media upload, or executes a complex database query, PHP allocates memory for that task. If any plugin or theme requires more than the configured limit, PHP terminates execution immediately and throws a fatal error.
The default value for memory_limit in most PHP installations is 128M. That is sufficient for a lightweight site with a handful of plugins. However, a fully equipped WordPress site with a page builder, WooCommerce, a caching plugin, a security scanner, and an SEO plugin easily exceeds 128M during a single page load — especially when the admin dashboard is involved.
Understanding the difference between the server-level limit (set in the master php.ini), the user-level override (set in .htaccess or a local php.ini), and the WordPress-level constant (set in wp-config.php) is essential before making any changes. PHP always applies the lowest value among what is permitted at each layer.
How to Check Your Current Memory Limit
Before touching any configuration file, confirm what limit PHP is actually enforcing. There are several reliable methods:
Method 1 — WordPress Site Health
In the WordPress admin dashboard go to Tools > Site Health > Info > Server. The panel shows "PHP Memory Limit" (the server's limit) and "WordPress Memory Limit" (what WordPress requested). If these two values differ, you know WordPress is asking for more than the server allows.
Method 2 — Temporary phpinfo() File
Create a file called info.php in your WordPress root and add:
<?php phpinfo(); ?>
Visit https://yourdomain.com/info.php in a browser and search for memory_limit. You will see both the "local" value (currently active) and the "master" value (server default). Delete the file immediately after checking — leaving phpinfo() publicly accessible is a security risk.
Method 3 — DirectAdmin PHP Configuration
Log into DirectAdmin and navigate to Advanced Features > PHP Configuration. The current memory_limit is displayed and can often be changed directly from this panel without editing any files.
Method 4 — WP-CLI
If you have SSH access to your server, WP-CLI gives you the fastest answer:
wp --info
The output includes "PHP binary memory limit" which reflects the true server-side value.
Three Methods to Increase PHP Memory Limit
There are three places to set the memory limit, each at a different layer of the stack. You should use the highest layer you have access to for the most reliable result.
Method 1 — wp-config.php (Recommended First Step)
Open wp-config.php in the root of your WordPress installation and add these two lines before the comment /* That's all, stop editing! */:
define( 'WP_MEMORY_LIMIT', '256M' ); define( 'WP_MAX_MEMORY_LIMIT', '512M' );
WP_MEMORY_LIMIT applies to regular front-end requests. WP_MAX_MEMORY_LIMIT applies to the wp-admin dashboard and background processes that require more resources. This method is quick and does not require server access, but it only works if the server's own limit is already at or above the value you specify.
Method 2 — .htaccess
On Apache servers running PHP as mod_php, you can override the memory limit at the directory level by adding this line to your root .htaccess:
php_value memory_limit 256M
This change affects all PHP files in that directory and its subdirectories. However, if your hosting uses PHP-FPM (as most modern DirectAdmin setups do), this directive will be ignored. PHP-FPM does not read php_value from .htaccess files.
Method 3 — php.ini
Create a file named php.ini in your website's public_html folder with:
memory_limit = 256M
For PHP-FPM environments this is often the correct approach when you cannot edit the global php.ini. On AsiaGB hosting with DirectAdmin you can also upload a custom php.ini through the File Manager and it will be picked up automatically.
A more complete set of recommended values for a typical WordPress site:
memory_limit = 256M max_execution_time = 300 upload_max_filesize = 64M post_max_size = 64M max_input_vars = 3000
Recommended Memory Limits by Site Type
The right value depends on your site's complexity. The table below provides starting points:
| Site Type | WP_MEMORY_LIMIT | WP_MAX_MEMORY_LIMIT | Notes |
|---|---|---|---|
| Simple blog / brochure site | 128M | 256M | Fewer than 10 plugins |
| Standard business site | 256M | 512M | 10–30 plugins, SEO plugin |
| WooCommerce + Page Builder | 512M | 512M | Elementor, Divi, many products |
| Large WooCommerce / Membership | 512M–1G | 1G | 1,000+ products, subscriptions |
Remember: the value in wp-config.php is a request, not a guarantee. PHP will silently cap the memory at the server's configured maximum. If you set 256M in wp-config.php but the server only allows 128M, PHP will use 128M.
Increasing Memory Limit via DirectAdmin on AsiaGB Hosting
If your site is hosted on AsiaGB with DirectAdmin, you can raise the memory limit without editing any files directly:
- Log into DirectAdmin at
yourdomain.com:2222 - Click Advanced Features > PHP Configuration
- Locate
memory_limitand enter your desired value, for example256M - Click Save — the change takes effect immediately without restarting Apache
If the PHP Configuration menu is not visible, your account may use the default server setting. In that case, place a custom php.ini file in public_html via the File Manager:
memory_limit = 256M max_execution_time = 300 upload_max_filesize = 64M post_max_size = 64M
After saving, clear any PHP opcode cache (if enabled) and refresh the Site Health page in WordPress to verify the new limit is active.
Verifying the New Memory Limit Is Active
After making your changes, always confirm the new limit is actually in effect before closing the terminal or file manager.
Via a Quick PHP Script
Create a temporary file and check the value at runtime:
<?php echo ini_get('memory_limit'); ?>
If it outputs 256M, the change is working. Remove the file after confirming.
Via WordPress Site Health
Go to Tools > Site Health > Info > Server and check the "PHP Memory Limit" line. It should now show your updated value.
Via WP-CLI
wp eval 'echo ini_get("memory_limit");'
Common Reasons the Fix Does Not Work
If you have followed all the steps above and the error persists, one of these situations is usually responsible:
- Server limit is lower than your requested value. PHP always applies the lower of the two. Contact your hosting provider to raise the server-level limit if your plan allows a higher allocation.
- Wrong php.ini location for PHP-FPM. PHP-FPM does not read
php.inifiles placed inpublic_htmlon all hosts. Check which php.ini path PHP actually reads by examining the phpinfo() output. - php_value ignored by PHP-FPM. The
php_valuedirective in .htaccess works only with mod_php, not PHP-FPM. Use a local php.ini or DirectAdmin settings instead. - Plugin memory leak. Some poorly coded plugins allocate memory without releasing it. Even raising the limit to 1G may not prevent the error if a plugin is leaking. Deactivate plugins one by one to identify the culprit.
- Stale opcode or object cache. If your server uses OPcache or an object cache like Redis, the old configuration may be cached. Flush all caches after making changes.
Pro Tip: If you have already raised the limit to 512M and still see memory errors, do not simply raise it again. Instead, deactivate all plugins, then reactivate them one at a time while monitoring memory usage with a plugin like Query Monitor. A plugin causing memory usage to spike by more than 20–30M per page load is a candidate for replacement. This bisect approach identifies memory leaks in minutes and is far more effective than chasing an ever-increasing limit.
Memory Limit and WordPress SEO Performance
Memory errors have a direct negative impact on SEO. When a page throws a fatal memory error, the HTTP response is either a 500 Internal Server Error or a blank page — both of which Googlebot records as a failed crawl. Repeated failures signal to Google that the page is unreliable, which can result in reduced crawl frequency and eventually de-indexing of affected URLs.
Core Web Vitals — specifically Largest Contentful Paint (LCP) and Time to First Byte (TTFB) — are also affected by memory pressure even before a fatal error occurs. When PHP is frequently bumping up against the memory ceiling, it spends time on garbage collection and memory reallocation instead of rendering content. This adds latency that hurts real user experience and Lighthouse scores.
Resolving memory issues proactively, before errors appear in Google Search Console, keeps your crawl budget healthy and your rankings stable.
Frequently Asked Questions
What is the recommended PHP memory limit for WordPress?
WordPress officially recommends a minimum of 256M for general sites. If you run WooCommerce, Elementor Pro, or other resource-heavy plugins, set it to 512M. Large stores with thousands of products or membership sites may need 512M to 1G. Avoid setting it unnecessarily high as it wastes server RAM.
I changed wp-config.php but still get Memory Limit Exceeded. Why?
WordPress cannot allocate more memory than the server's PHP limit allows. If the server's php.ini caps memory at 128M, WordPress cannot go higher even if you define 256M in wp-config.php. Check the actual limit via phpinfo() or DirectAdmin, then raise the server-level limit through .htaccess, user php.ini, or contact your hosting provider.
What is the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?
WP_MEMORY_LIMIT controls memory available to the front-end (default 40M). WP_MAX_MEMORY_LIMIT sets the ceiling for the wp-admin dashboard and background tasks (default 256M). Set WP_MEMORY_LIMIT to at least 256M and WP_MAX_MEMORY_LIMIT to at least 512M for smooth admin operations like media uploads and plugin updates.
Can WordPress Memory Limit Exceeded harm my SEO?
Yes. Memory errors cause pages to load with a fatal error or blank White Screen of Death. When Googlebot crawls these broken pages it registers a server error, which degrades Core Web Vitals scores. If important pages remain broken long enough they can be de-indexed. Fix memory errors as soon as they appear.
Full-Featured DirectAdmin Hosting by AsiaGB
AsiaGB Hosting supports DirectAdmin with PHP 8.3 and MySQL — starting at 500 THB/year
View Hosting Plans