Help

How to increase the WordPress memory limit

To increase the WordPress memory limit, add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php, above the “stop editing” comment. WordPress can only go as high as PHP allows, so raise memory_limit in cPanel too if the limit does not change. Check the result in Tools › Site Health › Info.

Updated · HostUpIndia team

What “Allowed memory size exhausted” means

The full message reads like Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes). A PHP request needed more memory than its limit, so PHP stopped. WordPress may show “There has been a critical error on this website” instead.

The first number is the limit in bytes: 134217728 bytes is 128 MB. Three settings decide it.

  • WP_MEMORY_LIMIT: the memory WordPress asks for when it loads your site.
  • WP_MAX_MEMORY_LIMIT: the memory for the dashboard, where updates and image edits need more. The default is 256M.
  • memory_limit: PHP’s own cap, set by your host. WordPress can only go as high as PHP lets it.

Check your current WordPress memory limit

Site Health shows the limits in effect. Check them before and after each change.

  • In WordPress, go to Tools › Site Health and open the Info tab.
  • Expand Server. Read “PHP memory limit” for your site and, if shown, “PHP memory limit (only for admin screens)” for the dashboard.
  • Expand WordPress Constants to see WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT.
  • Can’t open the dashboard? Check memory_limit in cPanel instead, as shown below.

Increase the memory limit in wp-config.php

256M suits most sites. Large stores and page builders may need 512M. The number is a cap for each request; it does not add memory to your plan.

New to this file? See wp-config.php explained.

  • In cPanel, open File Manager and go to your WordPress folder, usually public_html.
  • Download a copy of wp-config.php, so you can undo the change.
  • Edit wp-config.php and search it for WP_MEMORY_LIMIT. If the line is there, change its value. A second copy of the line causes a PHP warning.
  • If it is not there, add define( 'WP_MEMORY_LIMIT', '256M' ); above the comment that says “stop editing”.
  • To raise the dashboard’s limit too, set WP_MAX_MEMORY_LIMIT the same way, such as define( 'WP_MAX_MEMORY_LIMIT', '512M' );.
  • Save the file.

Raise the PHP memory_limit in cPanel

If Site Health still shows the old value, PHP’s own limit is lower and your host’s settings stop WordPress from raising it. Raise memory_limit itself.

  • In cPanel, open MultiPHP INI Editor. On some hosts the setting is in Select PHP Version › Options instead.
  • In Basic Mode, choose the domain of your WordPress site.
  • Set memory_limit to at least the value of WP_MEMORY_LIMIT, such as 256M. If you set WP_MAX_MEMORY_LIMIT higher, match that.
  • Select Apply.
  • No editor in cPanel? If your host allows it, add memory_limit = 256M to a php.ini or .user.ini file in your WordPress folder.
  • If the value will not go higher, your plan sets the cap. Check your plan in your client area, or ask your host.

Check that the new limit works

Nothing needs a restart. The new limit applies from the next page load; a .user.ini change can take a few minutes.

  • Reload Tools › Site Health › Info.
  • Check that Server and WordPress Constants show the new limits.
  • Repeat the task that failed, such as the update, the import or the page that showed the error.

If WordPress still runs out of memory

A higher limit does not fix a plugin or theme that uses too much memory. If the error comes back, find the cause.

  • Turn on debug logging, as in how to fix the WordPress critical error.
  • Open wp-content/debug.log and find the last Allowed memory size line.
  • Note the folder after wp-content/plugins/ or wp-content/themes/ in that line. It often points to the cause, but not always.
  • Deactivate plugins one at a time, loading the failing page after each. The one that stops the error is the cause.
  • Update or replace that plugin or theme, or ask its developer for a fix.
  • When you are done, set WP_DEBUG back to false and remove the two lines you added.
  • Delete wp-content/debug.log. Anyone who knows its address can read it.

HostUpIndia WordPress hosting

HostUpIndia WordPress plans come with WordPress pre-installed on LiteSpeed, NVMe storage and free SSL. Every plan includes cPanel for the steps above, and daily backups kept 30 days, so there is a restore point before you change anything.

  • From ₹149 a month on 3-year billing. Prices exclude 18% GST. See WordPress plans.
  • Support tickets and email are received 24 hours a day, 7 days a week; WhatsApp is open for questions from 10 am to 7 pm IST, Monday to Saturday.
  • Free website migration by the HostUpIndia in-house team.
  • More help guides.