Client Login
KES
Client LoginRegister
cPanel & Control Panels

Fix "Allowed Memory Size Exhausted" PHP Errors in cPanel

Updated 3 min read Hostnali team

You open your website, or try to upload an image or install a plugin, and instead of the page you see:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /home/user/public_html/wp-includes/...

This guide explains what the error means, how to raise PHP’s memory limit in cPanel, and, just as important, how to find what is using so much memory in the first place.

What the error means

Every PHP script on the server is allowed a maximum amount of memory, set by the memory_limit setting. The number in the message is that limit in bytes:

Bytes in the errorLimit
3355443232 MB
6710886464 MB
134217728128 MB
268435456256 MB

When a script needs more than the limit, PHP stops it and shows this error. The “tried to allocate” figure is just the last small piece it asked for; the real total was much larger.

Common causes

  • A heavy or badly written plugin or theme, often a page builder, a backup plugin or a security scanner.
  • Large image uploads, which PHP has to load fully into memory to resize.
  • Imports and exports of big files (WooCommerce products, XML imports).
  • An outdated plugin that is incompatible with your PHP version.
  • A limit that is simply too low for your site, such as 64 MB for a WooCommerce store.

Fix 1: raise memory_limit in cPanel

On Hostnali hosting you can change PHP settings yourself:

  1. Log in to cPanel.
  2. Open Select PHP Version (in the Software section) and click Options, or open MultiPHP INI Editor.
  3. Find memory_limit and choose a higher value, such as 256M. For most WordPress sites 256M is plenty; large WooCommerce stores may use 512M.
  4. Save, then reload the page that showed the error.

The change applies straight away; there is nothing to restart.

Fix 2: tell WordPress it may use more memory

WordPress has its own limit on top of PHP’s. In File Manager, edit wp-config.php and add these lines above the line that says That’s all, stop editing!:

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

WP_MAX_MEMORY_LIMIT is used for admin tasks such as image processing and updates. WordPress can’t go above the PHP limit you set in Fix 1.

Fix 3: a .htaccess setting (if the options above aren’t available)

Our servers run LiteSpeed, which also reads PHP settings from .htaccess. Add this line to the .htaccess file in your site’s folder:

php_value memory_limit 256M

If the site shows a 500 error after the change, remove the line and use Fix 1 instead.

Find the real cause

Raising the limit hides the symptom; if something is leaking memory it will hit the new limit too. To find it:

  1. Note where the error happens. The file path in the message often names the plugin or theme, for example /wp-content/plugins/plugin-name/.
  2. Deactivate plugins one by one (or all at once, then reactivate them one at a time) until the error stops.
  3. Switch to a default theme briefly to rule out your theme.
  4. Check the error log in cPanel (Metrics → Errors) for repeated errors around the same time.
  5. Resize images before uploading, to about 2,000 pixels wide.
  6. Update PHP and plugins. Newer PHP versions use memory more efficiently.

When to upgrade

If your site regularly needs more than 512 MB per request, or many visitors trigger heavy tasks at once, it has outgrown shared resources. Cloud or corporate hosting gives guaranteed resources while we still manage the server.

Frequently asked questions

What memory limit should I use for WordPress?

256M suits most WordPress sites. WooCommerce stores and sites with page builders may need 512M.

I raised the limit but the error still appears. Why?

Either the new limit isn’t applied (check Select PHP Version → Options), or a plugin is using memory in a loop. Find it by deactivating plugins one at a time.

Can Hostnali support fix it for me?

Yes. Open a ticket with the page address and the full error message, and our team will look at it.

Keep reading

Related articles

Start your website with Hostnali

Hosting, domains and 24/7 support from one team.