WP AI Agent
Features Pricing Blog Contact Download Plugin Manage Subscription Get Free Key →

How to Increase the WordPress Memory Limit: A Complete Guide

· · 8 min read

Knowing how to increase the WordPress memory limit is one of the most essential troubleshooting skills for any WordPress site owner or developer. When WordPress runs out of allocated PHP memory, you'll encounter the dreaded "Allowed memory size exhausted" fatal error, which can take your site offline and frustrate visitors. Fortunately, increasing the memory limit is straightforward once you know where to look.

What Is the WordPress Memory Limit and Why Does It Matter?

PHP, the scripting language that powers WordPress, runs within a memory boundary set by your server. This boundary — the memory limit — defines the maximum amount of RAM a single PHP process can consume. WordPress itself has its own internal memory ceiling that sits on top of the server-level limit.

When your site loads a page, WordPress, its plugins, and your active theme all consume memory simultaneously. Complex plugins like WooCommerce, page builders such as Elementor, or large image libraries can push memory usage past the default threshold. The result is a white screen, a 500 error, or a PHP fatal error message.

Default WordPress Memory Limits

By default, WordPress sets its memory limit to 40 MB for the front end and 256 MB for the admin area (WP_MAX_MEMORY_LIMIT). Most managed WordPress hosts allocate between 128 MB and 512 MB at the server level, but budget shared hosting may cap you at just 64 MB or 128 MB. Understanding both limits is key before you start editing files.

Common Symptoms of Insufficient Memory

  • White Screen of Death (WSoD) when loading a page or activating a plugin
  • "Fatal error: Allowed memory size of X bytes exhausted" messages
  • WordPress dashboard freezing or timing out during updates
  • Media uploads failing without a clear error message
  • Certain plugins or themes refusing to activate

Method 1: Increase the WordPress Memory Limit via wp-config.php

The most reliable and widely recommended method is to define the memory limit directly inside wp-config.php, the core configuration file that WordPress loads before anything else. This approach works regardless of your hosting provider.

Step-by-Step Instructions

  1. Connect to your server using FTP, SFTP, or your hosting control panel's File Manager.
  2. Navigate to the root directory of your WordPress installation (typically public_html or www).
  3. Download or open wp-config.php in a text editor. Always create a backup before editing.
  4. Locate the line that reads /* That's all, stop editing! Happy publishing. */
  5. Add the following lines immediately before that comment:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
  1. Save the file and re-upload it to your server if you edited it locally.
  2. Reload your WordPress site and check whether the error has cleared.
  3. Verify the new memory limit by navigating to Tools > Site Health > Info > Server inside your WordPress dashboard.

Note: WP_MEMORY_LIMIT controls the front-end memory ceiling, while WP_MAX_MEMORY_LIMIT sets the ceiling for admin-area tasks. You cannot set either value higher than the PHP-level limit configured on your server — WordPress can only work within what PHP allows.

Method 2: Edit the php.ini File

If editing wp-config.php alone does not resolve the issue, the underlying PHP memory limit set by your server may be too low. Adjusting php.ini raises the ceiling at the PHP level, giving WordPress more room to work with.

How to Locate and Edit php.ini

  1. Log in to your hosting control panel (cPanel, Plesk, etc.).
  2. Look for a PHP Configuration or Select PHP Version option, which often includes a graphical interface for changing memory_limit.
  3. If a graphical option is unavailable, access your server via SSH or FTP and locate the php.ini file. On shared hosts it may be inside your home directory or inside the public_html folder.
  4. Open php.ini and find the line that begins with memory_limit. If no such line exists, add one.
  5. Change or add the value:
memory_limit = 256M
  1. Save the file.
  2. Restart PHP-FPM or Apache if you have server-level access, or contact your host to apply the change.
  3. Confirm the update by creating a temporary PHP file with <?php phpinfo(); ?>, loading it in a browser, and searching for memory_limit.

Using a Custom php.ini on Shared Hosting

Many shared hosts do not allow you to edit the main php.ini directly. In that case, you can often create a custom php.ini file inside your public_html directory containing only the line memory_limit = 256M. Some hosts use a file called php5.ini or honor the PHP settings placed inside .htaccess instead — check your host's documentation.

Method 3: Use the .htaccess File

On Apache-based servers, you can set PHP directives via the .htaccess file, which sits in your WordPress root directory. This is a useful fallback when both wp-config.php and php.ini options are restricted.

Adding the Memory Directive

  1. Connect to your server via FTP or your hosting File Manager.
  2. Locate the .htaccess file in your WordPress root directory. It may be hidden — enable the option to show hidden files in your FTP client.
  3. Open the file and add the following line at the top, before any existing WordPress rules:
php_value memory_limit 256M
  1. Save and upload the file.
  2. Test your site to confirm the error is resolved.

Caution: This method does not work on Nginx-based servers or on Apache servers running PHP in CGI mode. If adding this line causes a 500 error, remove it immediately — your server does not support this directive in .htaccess.

Method 4: Increase the Memory Limit Using WP-CLI

For developers who prefer the command line, WP-CLI provides a fast way to query and adjust WordPress settings without touching files through a graphical interface. While WP-CLI cannot directly set the PHP-level limit, it can confirm your current configuration and help you manage constants via configuration commands.

Checking the Current Memory Limit with WP-CLI

  1. SSH into your server.
  2. Navigate to your WordPress root directory.
  3. Run the following command to view your current WordPress memory configuration:
wp eval 'echo WP_MEMORY_LIMIT;'
  1. To set the constant directly from the command line (requires WP-CLI config manipulation or a shell alias), you can use:
wp config set WP_MEMORY_LIMIT 256M --raw
  1. Verify the change by running the eval command again.

Why WP-CLI Is Useful for Memory Tasks

WP-CLI lets you bypass the WordPress dashboard entirely, which is valuable when a memory exhaustion error has made the admin area inaccessible. You can deactivate memory-hungry plugins, regenerate thumbnails, or run database optimizations — all from the command line without triggering the same PHP memory ceiling that breaks the browser-based interface.

Best Practices and Troubleshooting Tips

Simply raising the memory limit is not always a permanent fix. If your site consistently needs 512 MB or more, something deeper may be wrong. Follow these best practices to keep memory usage healthy long-term.

Identify Which Plugin or Theme Is Using the Most Memory

  • Install a plugin like Query Monitor to see real-time memory usage per page load.
  • Deactivate plugins one by one and check memory usage after each deactivation to isolate the culprit.
  • Switch to a default WordPress theme (Twenty Twenty-Four) temporarily to rule out theme-related memory bloat.

Choose the Right Memory Value

  • 128M — Suitable for simple blogs with few plugins.
  • 256M — Recommended for most small-to-medium WordPress sites.
  • 512M — Appropriate for WooCommerce stores, membership sites, or sites with heavy page builders.
  • 1G or more — Only needed for large multisite networks or high-traffic enterprise installations.

Contact Your Hosting Provider

If none of the above methods work, the server-level configuration may be locked by your host. Contact your hosting support team and request a memory limit increase. Reputable hosts will accommodate this, especially if you are on a VPS, dedicated, or managed WordPress hosting plan. If your host refuses or the limit is structurally too low for your needs, it may be time to upgrade your hosting plan.

Monitor Memory After Making Changes

After increasing the memory limit, keep an eye on your server's overall RAM usage. If your VPS or shared hosting plan has a fixed amount of physical memory, allocating too much to PHP can starve other processes like MySQL, leading to database connection errors. A good rule of thumb is to allocate no more than 50–60% of your total server RAM to PHP memory limits.

Frequently Asked Questions

What is the recommended WordPress memory limit?

For most WordPress sites, a memory limit of 256M is sufficient. WooCommerce and page-builder-heavy sites often benefit from 512M. The WordPress Codex recommends a minimum of 64M, but modern sites with multiple plugins routinely need 256M or more to run without errors.

Why is my memory limit not changing after editing wp-config.php?

If your wp-config.php edit is not taking effect, the server-level PHP memory limit is likely lower than the value you set. WordPress cannot exceed the PHP ceiling. Edit your php.ini or .htaccess file (as described above) to raise the PHP-level limit first, then the wp-config.php value will be honored.

Will increasing the WordPress memory limit slow down my site?

No — increasing the memory limit itself does not slow your site. It simply allows PHP processes to use more RAM when needed. However, if underlying code is inefficient and consuming excessive memory, performance may still be poor. Always investigate the root cause of high memory usage rather than only raising the limit.

Can I increase the WordPress memory limit from inside the admin dashboard?

WordPress does not provide a native settings screen for changing the memory limit. You must edit server or WordPress configuration files directly. Some caching and optimization plugins (such as WP Rocket or LiteSpeed Cache) display current memory usage but do not change the limit themselves. Use the file-editing methods described in this guide, or ask your hosting provider for help.

Increasing the WordPress memory limit is a practical skill that saves time and prevents costly downtime. Whether you choose to edit wp-config.php, php.ini, .htaccess, or use WP-CLI, following the steps outlined in this guide will get your site running smoothly again. If you find yourself repeatedly making server-level changes like these, consider using WP AI Agent — an AI-powered chat tool that lets you manage, troubleshoot, and configure WordPress tasks through simple natural-language conversation, so you can resolve issues like memory limits without ever opening a file editor.

Ready to manage WordPress with AI?

Get 100,000 tokens free every month. No credit card required.

Get Your Free License Key →

More from the blog