Increasing the WordPress Memory Limit

Increasing the WordPress Memory Limit

If WordPress or a plugin throws a fatal error about memory, you need to raise the PHP memory limit. This article explains what the error means, how to fix it in KPanel, and what limits are appropriate for different site types.

What the error looks like

A memory exhaustion error typically appears as:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate X bytes)

You may also see it as a blank white screen (sometimes called a "white screen of death") with no other message, a brief flash of an error before the page redirects, or an error displayed only in the wp-admin dashboard.

How to increase the memory limit in KPanel

KPanel lets you adjust the PHP memory limit directly from the browser -- no file editing required.

  1. Log in to kpanel.kapsulecloud.com and open Websites.
  2. Click the domain you want to change.
  3. In the site navigation bar, click Advanced, then PHP.
  4. Under the PHP settings section, find Memory limit.
  5. Click the dropdown next to it and select your desired value: 128M, 256M, 512M, 1024M, or 2048M.
  6. Click Save Settings.

Changes apply on the next PHP request. No server restart is needed.

The memory limit is written to a .user.ini file in your site root. KPanel manages this file for you.

Site typeRecommended memory limit
Small brochure site or blog128M (default)
WordPress with a premium theme and several plugins256M
WooCommerce with a moderate product catalogue256M
WooCommerce with many products, subscriptions, or heavy plugins512M
Large multisite network or complex membership site512M to 1024M

If you are unsure, start at 256M. That resolves the majority of memory errors. Increase further only if the error persists.

Setting the limit in wp-config.php

For sites where KPanel PHP settings are not available, or if you want to cap the memory WordPress itself requests (independently of the PHP limit), you can add a constant to wp-config.php:

  1. Connect via SFTP or open Files > File Manager in KPanel.
  2. Navigate to the root of your WordPress installation and open wp-config.php.
  3. Add the following line before the /* That's all, stop editing! */ comment:
define('WP_MEMORY_LIMIT', '256M');

For WooCommerce or admin-heavy operations you can also set:

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

WP_MAX_MEMORY_LIMIT applies to the wp-admin area specifically, which typically needs more memory than the front end.

Note: WP_MEMORY_LIMIT can only request memory up to the PHP memory_limit set in your server configuration. Setting it higher than the server limit has no effect. Use the KPanel PHP settings above to set the actual server-side ceiling.

PHP version also matters

If memory errors appeared after a PHP version change, the new version may handle memory allocation slightly differently, or a plugin may not be compatible with the new version. Check the PHP tab in KPanel to see which version is active. WordPress recommends PHP 8.1 or higher.

WooCommerce-specific notes

WooCommerce's own documentation recommends a minimum of 256M. Stores running:

  • Variable products with many variations
  • The WooCommerce Subscriptions extension
  • Multiple payment gateway plugins
  • Heavy inventory management plugins

...will often need 512M or more. If WooCommerce admin pages are slow or timing out, check the memory limit first.

You can view WooCommerce's status report at WooCommerce > Status in wp-admin. It lists the current memory limit and whether it meets the recommended minimum.

Still seeing memory errors?

If raising the limit does not resolve the error, the problem may be:

  • A plugin with a memory leak. Deactivate plugins one at a time to find the culprit.
  • A theme function running on every page load. Switch to a default theme temporarily to test.
  • A very large import or export operation. These often need a higher max_execution_time as well -- adjustable in the same KPanel PHP settings panel.

Contact support if the error persists after increasing memory to 512M and eliminating obvious plugin causes.

Was this article helpful?

Still need help?

Our support team is here on business days, NZT.

Back to Help Centre