FLASH SALE Get 10% OFF everything using the coupon code: FLASH10 View Pricing Plans →

How to Increase WordPress Memory Limit

The WordPress memory limit controls how much server RAM your site’s PHP scripts can use. To increase it, add define(‘WP_MEMORY_LIMIT’, ‘256M’); to your wp-config.php file just before the “stop editing” line. If that doesn’t work, you can also adjust it through .htaccess, php.ini, or your hosting control panel.

How to Increase WordPress Memory Limit

If you’ve ever seen the “Fatal error: Allowed memory size exhausted” message or a warning that your site’s memory is below the recommended 256MB, your WordPress memory limit is too low. This memory exhausted error is one of the most common WordPress issues. WordPress defaults to just 40MB for single sites and 64MB for multisite, which is rarely enough for modern themes, plugins, and media-heavy content.

The good news: fixing this takes about two minutes. In this guide, we’ll cover how to check your current limit and walk through five methods to increase it, from the quickest wp-config.php edit to hosting-level changes.



What Is the WordPress Memory Limit?

The WordPress memory limit is the maximum amount of server RAM that a single PHP script is allowed to use when running your site. You might also see it referred to as the “wp memory limit” or “PHP memory limit” in hosting documentation and plugin settings. Every page load, admin action, and plugin process runs through PHP, and each of those processes needs memory to execute. The memory limit acts as a cap to prevent one process from consuming all available server resources.

WordPress manages memory through two constants defined in your wp-config.php file:

  • WP_MEMORY_LIMIT controls memory for your site’s front-end processes (page loads, REST API calls, cron jobs). It defaults to 40MB for single-site installations and 64MB for WordPress Multisite.
  • WP_MAX_MEMORY_LIMIT controls memory for admin-area tasks like plugin updates, image processing, and content imports. It defaults to 256MB.

These defaults are hardcoded in WordPress core (wp-includes/default-constants.php). When WordPress loads, it uses PHP’s ini_set() function to request the amount of memory specified by these constants. However, there’s an important catch: WordPress cannot request more memory than your server’s PHP memory_limit allows. That server-level setting (configured in php.ini) is the hard ceiling.

Quick Tip: WordPress has TWO memory constants. WP_MEMORY_LIMIT handles your site’s front end (default 40MB), while WP_MAX_MEMORY_LIMIT handles the admin area (default 256MB). When people say “increase WordPress memory limit,” they usually mean the front-end constant.


Signs Your WordPress Memory Limit Is Too Low

The most obvious sign is a fatal error message displayed on your screen or sent to your admin email:

“Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)”

In newer versions of WordPress, you might not see the technical error at all. Instead, you’ll see a generic message: “There has been a critical error on this website.” The full error details will be in your admin email inbox or your site’s error log.

Other common signs include:

  • “Insufficient memory limit” warning. Some plugins, particularly import tools, page builders, and migration plugins, check your WP_MEMORY_LIMIT value during setup. If it’s below their minimum (usually 256MB), they’ll display a warning like “The memory limit of your site is below the recommended 256MB.” This doesn’t necessarily mean your server lacks memory; it means WordPress’s internal limit is set too low.
  • White Screen of Death (WSOD). Your site displays a completely blank page, often right after activating a new plugin or theme.
  • Failed media uploads. You try to upload an image and get an “HTTP error” or the upload just stalls.
  • Slow or unresponsive admin panel. The WordPress dashboard takes a long time to load, or actions like saving posts and installing plugins time out.
  • Plugin and theme activation failures. You click “Activate” and nothing happens, or you get redirected to an error page.

If you’re experiencing any of these, checking and increasing your WordPress memory limit should be your first troubleshooting step.


How to Check Your Current WordPress Memory Limit

Before changing anything, find out what your current limit is. This helps you confirm the problem and verify that your fix actually worked.

WordPress includes a built-in diagnostic tool that shows your memory configuration:

  1. Go to Tools → Site Health in your WordPress dashboard.
  2. Click the Info tab at the top.
  3. Expand the Server section.
  4. Find PHP memory limit. This shows the actual limit your server enforces.
  5. Also expand WordPress Constants to see WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT values.
Site Health - PHP memory limit

The PHP memory limit is the number that matters most. If WP_MEMORY_LIMIT is set higher than the PHP memory limit, the PHP limit still wins.

Using Your Hosting Control Panel

If you have access to cPanel, go to Software → MultiPHP INI Editor (or PHP Selector → Options) and look for the memory_limit directive. In Plesk, check your domain’s PHP Settings page.

Checking wp-config.php Directly

Open your wp-config.php file and search for WP_MEMORY_LIMIT. If you find a line like define(‘WP_MEMORY_LIMIT’, ’64M’);, that’s your current WordPress memory limit. If the line doesn’t exist, WordPress is using the default (40MB for single sites, 64MB for multisite).


Upgrade Your Website with a Premium WordPress Theme

Find a theme that you love and get a 10% discount at checkout with the FLASH10 code

Choose your theme

This is the fastest and most widely applicable method. It works on virtually every hosting setup and directly targets WordPress’s memory allocation.

Before you start: Back up your site before editing any core files. A typo in wp-config.php can take your site offline.

Step-by-Step Instructions

1. Access your WordPress root directory. Connect via FTP (using FileZilla or Cyberduck) or open File Manager in your hosting control panel. Navigate to your site’s root folder (usually public_html or www).

2. Open wp-config.php. Right-click the file and select Edit or View/Edit.

3. Find this line:

/* That's all, stop editing! Happy publishing. */

4. Add the following code just ABOVE that line:

define('WP_MEMORY_LIMIT', '256M');

To also increase the admin-side memory limit, add:

define('WP_MAX_MEMORY_LIMIT', '512M');

If a WP_MEMORY_LIMIT line already exists in your file, change its value instead of adding a duplicate.

5. Save the file and upload it back to your server (if using FTP).

WordPress memory limit in wp-config.php
Site TypeRecommended WP_MEMORY_LIMIT
Small blogs, brochure sites128MB
Business sites, page builders256MB
WooCommerce stores, membership sites512MB

Start with 256MB. That’s enough for the vast majority of WordPress sites. Only go higher if you still see errors after setting 256MB.

If This Doesn’t Work

There’s one common reason this method fails: your hosting server’s PHP memory_limit is lower than what you set in wp-config.php. WordPress can’t grant itself more memory than the server allows. If you set WP_MEMORY_LIMIT to 256MB but your server’s PHP limit is 128MB, you’ll only get 128MB.

Check your PHP memory limit in Site Health (see the section above). If it’s lower than 256MB, you’ll need to increase it at the server level using one of the methods below.


Method 2: Increase PHP Memory Limit via .htaccess

The .htaccess file can override certain PHP settings at the server level. This method sets the PHP memory limit directly, bypassing WordPress’s internal configuration.

Important: This only works on Apache servers with mod_php enabled. If your site runs on Nginx or LiteSpeed, skip to Method 3 or 4.

Step-by-Step Instructions

1. Access your WordPress root directory via FTP or File Manager.

2. Find the .htaccess file. It’s in the same folder as wp-config.php. If you don’t see it, enable “Show Hidden Files” in your FTP client or File Manager settings.

3. Open the file and add this line before # END WordPress:

php_value memory_limit 256M

4. Save and upload the file.

Go to Site Health → Info → Server to confirm the new PHP memory limit is active.

When to Use This Method

Use .htaccess when the wp-config.php method didn’t increase your WordPress memory limit because the server’s PHP limit was the bottleneck. The .htaccess directive changes the PHP-level limit, not just WordPress’s internal request.

If your host uses Nginx instead of Apache, the .htaccess file has no effect. You’ll need to edit php.ini (Method 3) or contact your host (Method 4).


Method 3: Increase PHP Memory Limit via php.ini

The php.ini file is the master configuration file for PHP. Changing the memory_limit directive here sets the limit at the server level, which affects all PHP applications on your account.

Locating php.ini

The location varies depending on your hosting setup:

  • Shared hosting: You usually don’t have access to the main php.ini. Some hosts let you create a custom php.ini or .user.ini file in your public_html folder. Check your host’s documentation.
  • VPS or dedicated server: The file is typically at /etc/php/8.x/fpm/php.ini or /etc/php/8.x/apache2/php.ini. Run php –ini via SSH to find the exact path.
  • cPanel: Use the MultiPHP INI Editor to change PHP settings through a graphical interface without touching files directly.

Step-by-Step Instructions

1. Open php.ini (or create a .user.ini file in your root directory).

2. Find the line:

memory_limit = 64M

3. Change it to:

memory_limit = 256M

4. Save the file. On a VPS, restart PHP-FPM (sudo systemctl restart php8.x-fpm). On shared hosting, changes usually take effect within a few minutes.

If you’re using cPanel’s MultiPHP INI Editor, select your domain, find memory_limit in the list, enter your desired value, and click Apply.

When to Use This Method

Use php.ini when you need to set the absolute server-level PHP memory limit. This is the most authoritative method for increasing your WordPress memory limit because it controls the ceiling that WordPress and .htaccess both operate under.


Method 4: Increase Memory Limit Through Your Hosting Provider

On managed hosting platforms and many shared hosting plans, you can’t directly edit php.ini or your .htaccess changes may be restricted. In these cases, contacting your host is the fastest and safest way to increase your WordPress memory limit.

Using cPanel or Plesk (If Available)

If your host provides a control panel:

  • cPanel: Go to MultiPHP INI Editor, select your domain, change memory_limit to 256M (or higher), and click Apply.
  • Plesk: Navigate to your domain’s PHP Settings page and update the memory limit.

Managed Hosting (WP Engine, Kinsta, Flywheel)

Managed WordPress hosts typically set generous defaults (256MB or higher), but you may need more for resource-heavy sites:

  • WP Engine: Memory limits depend on your plan. Contact support or adjust through the User Portal’s PHP settings.
  • Kinsta: Adjust PHP settings in the MyKinsta dashboard or contact support for increases beyond plan defaults.
  • Flywheel: Contact their support team with your specific memory needs.

Contacting Support Directly

If none of the self-service options work:

  1. Open a support ticket with your hosting provider.
  2. Request that they increase your PHP memory_limit to 256MB (or 512MB for WooCommerce sites).
  3. Mention the specific error message you’re seeing.
  4. Most hosts handle this within minutes.

Method 5: Use a WordPress Plugin

If you prefer not to edit configuration files, a few wp memory limit plugins can adjust your WordPress memory limit from the dashboard:

  • Health Check & Troubleshooting (by the WordPress.org community): Helps diagnose memory issues and provides server information. It won’t directly change your limit, but it’s useful for identifying problems.
  • WP Server Health Stats: Displays memory usage and server details in your dashboard.

Be aware that plugins claiming to “increase” your memory limit are typically just adding the same define(‘WP_MEMORY_LIMIT’, ‘256M’); line to wp-config.php behind the scenes. They can’t override your server’s PHP memory_limit cap.

If you’re comfortable opening a file and pasting one line of code, Method 1 is more direct and doesn’t add another plugin to your site. But if editing files feels risky, a plugin provides a safer interface.


WordPress Memory Limit vs. PHP Memory Limit: What’s the Difference?

This is the most common point of confusion, and it explains why Method 1 sometimes “doesn’t work.”

There are three memory settings that interact with each other:

1. PHP memory_limit (set in php.ini) is the hard ceiling. It controls how much RAM each PHP process on your server can use. This is set by your hosting provider or server configuration.

2. WP_MEMORY_LIMIT (set in wp-config.php) is WordPress’s request to PHP. When WordPress loads, it calls ini_set(‘memory_limit’, WP_MEMORY_LIMIT) to ask PHP for this much memory. But PHP won’t grant more than its own memory_limit.

3. WP_MAX_MEMORY_LIMIT (set in wp-config.php) is a separate request for admin-area tasks. WordPress applies this higher limit when you’re in the dashboard, running updates, or processing images.

The Key Rule

WP_MEMORY_LIMIT can never exceed PHP memory_limit. If you set WP_MEMORY_LIMIT to 512MB but PHP memory_limit is 128MB, your site only gets 128MB.

Quick Reference Table

SettingFileControlsDefaultCan Exceed Server Limit?
WP_MEMORY_LIMITwp-config.phpFront-end WordPress processes40MB (64MB multisite)No
WP_MAX_MEMORY_LIMITwp-config.phpAdmin area (dashboard, updates)256MBNo
memory_limitphp.iniAll PHP processes on the serverVaries by host (commonly 128–512MB)N/A (this IS the server limit)

Which Method Should You Use?

  • Need more memory for your site? Start with Method 1 (wp-config.php). This handles most cases.
  • Method 1 didn’t help? Your server’s PHP limit is the bottleneck. Use Method 2 (.htaccess) or Method 3 (php.ini) to raise it.
  • Can’t edit server files? Contact your host (Method 4).

How to Reduce WordPress Memory Usage

Increasing the WordPress memory limit fixes the immediate error, but sometimes the real problem is excessive memory consumption. If you’re hitting 256MB regularly, it’s worth investigating what’s using all that memory.

Identify Memory-Hungry Plugins

Install the Query Monitor plugin temporarily. It shows memory usage per component, so you can identify which plugins consume the most resources. Common culprits include page builders with live preview, WooCommerce with dozens of extensions, and backup plugins that run during page loads.

If a single plugin is using 80MB+ on its own, consider whether you really need it or whether a lighter alternative exists.

Optimize Your Setup

A few maintenance practices keep memory usage in check:

  • Update to PHP 8.x. PHP 8 uses significantly less memory than PHP 7.x for the same workload. Check your current version in Site Health and ask your host to upgrade if needed.
  • Remove unused plugins and themes. Even deactivated plugins can load autoloaded data into memory. Delete anything you’re not using.
  • Optimize images before uploading. Large images require more memory for processing (resizing, thumbnail generation). Compress images before uploading them to WordPress.
  • Keep everything updated. Newer versions of WordPress, themes, and plugins often include memory optimizations. Staying current helps your site run more efficiently.

For a deeper look at performance improvements, check out our WordPress speed optimization guide.


FAQ

What is the default WordPress memory limit?

WordPress defaults to 40MB for single-site installations and 64MB for multisite. The admin area uses a separate constant (WP_MAX_MEMORY_LIMIT) that defaults to 256MB. These defaults are defined in WordPress core and can be overridden in wp-config.php.

How do I check my current WordPress memory limit?

Go to Tools → Site Health → Info in your WordPress dashboard. Expand the Server section to find your PHP memory limit. Also check WordPress Constants to see the WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT values currently active on your site.

What should I set my WordPress memory limit to?

256MB works well for most WordPress sites. WooCommerce stores, membership sites, or sites running many plugins may need 512MB. Start with 256MB and only increase if you continue to see memory-related errors.

Why didn’t increasing WP_MEMORY_LIMIT fix my error?

Your server’s PHP memory_limit is likely lower than the value you set in wp-config.php. WordPress cannot exceed the server’s limit. Check your PHP memory limit in Site Health, then use the .htaccess or php.ini methods (or contact your host) to raise the server-level limit.

What does “insufficient memory limit” mean?

This warning appears when a plugin checks your WP_MEMORY_LIMIT value and finds it below its minimum requirement, which is usually 256MB. You’ll commonly see it with import tools, page builders, and migration plugins. Fix it by adding define(‘WP_MEMORY_LIMIT’, ‘256M’); to your wp-config.php file.

Is it safe to increase the WordPress memory limit?

Yes. You’re simply telling PHP it can use more of your server’s available RAM for WordPress processes. Setting it to 256MB or 512MB is standard practice. Just don’t set it higher than your hosting plan allows, as the extra allocation won’t take effect and may mask performance problems that should be addressed.

Can I increase the memory limit on shared hosting?

It depends on your host. Some shared hosts cap PHP memory at 128MB or 256MB regardless of what you set in wp-config.php. Try the wp-config.php method first. If the value doesn’t change in Site Health, your host is enforcing a cap. Contact their support team to ask about raising it, or consider upgrading to a plan with more resources.

What’s the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?

WP_MEMORY_LIMIT controls memory for your site’s front-end pages and processes (default 40MB). WP_MAX_MEMORY_LIMIT controls memory for admin-area tasks like updates, image editing, and imports (default 256MB). Both are defined in wp-config.php, and neither can exceed the server’s PHP memory_limit.


Wrapping Up

Most WordPress memory limit errors are fixed in under two minutes with a single line in wp-config.php. Here’s a quick recap of all five methods to increase your WordPress memory limit:

  1. wp-config.php (recommended): Add define(‘WP_MEMORY_LIMIT’, ‘256M’); before the “stop editing” line.
  2. .htaccess: Add php_value memory_limit 256M (Apache servers only).
  3. php.ini: Change memory_limit = 256M at the server level.
  4. Hosting provider: Use cPanel, Plesk, or contact support to raise the limit.
  5. Plugin: Use a dashboard tool to adjust the setting without editing files.

If the error persists after increasing the limit, the issue may not be the limit itself. A faulty plugin or theme could be consuming memory in an endless loop. Try deactivating plugins one by one to isolate the problem, or enable WP_DEBUG to get more detailed error information.

For more WordPress troubleshooting guides, check out our articles on how to increase the maximum file upload size and editing your WordPress PHP.ini file.

Related Posts

Upgrade Your Website with a Premium WordPress Theme

Find a theme that you love and get a 10% discount at checkout with the FLASH10 code

Choose your theme
Subscribe to the WPZOOM newsletter.

Join 200,000 people. Get our latest news & releases delivered to your inbox.

Leave a Reply

*

*