How to increase the WordPress memory limit
Help centreOn this page
This guide shows how to give WordPress more memory when you see “Allowed memory size exhausted” or a plugin asks for a higher limit.
How the two limits work
There are two settings, and both matter:
- PHP memory_limit is the most memory one PHP process can use. It is set for your account in cPanel.
- WP_MEMORY_LIMIT is how much of that WordPress asks for. It is set in
wp-config.php.
WordPress can’t use more than PHP allows, so if you raise one, check the other.
Raise the PHP memory limit in cPanel
- Log in to cPanel.
- Open Select PHP Version, then click the Options tab. On some accounts this is called MultiPHP INI Editor instead. The wording may vary.
- Find memory_limit.
- Choose a higher value, such as 256M or 512M.
- The change saves automatically in Options. In MultiPHP INI Editor, pick your domain first and click Apply after changing the value.
Raise the WordPress memory limit
- In cPanel, open File Manager.
- Go to your WordPress folder (usually
public_html). - Right-click
wp-config.phpand choose Edit. - Add these lines above the line that says “That’s all, stop editing!”:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
- Save the file.
WP_MEMORY_LIMIT covers the front of your site. WP_MAX_MEMORY_LIMIT covers the dashboard, which sometimes needs more for jobs like resizing images. If either line is already in the file, change the number rather than adding it twice.
Check it worked
In WordPress, go to Tools, then Site Health, then the Info tab. Open the Server section to see the PHP memory limit, and WordPress Constants to see WP_MEMORY_LIMIT.
If it doesn’t work
- The new value doesn’t show. Check the PHP version you edited is the one your site uses. See how to change your PHP version.
- You still get memory errors at 512M. A plugin or theme is probably stuck in a loop or doing too much at once. Turn plugins off one by one to find it. See how to fix the white screen of death.
- The site breaks after editing wp-config.php. Check for a missing quote or semicolon, or remove the lines you added.
Good to know
Our hosting accounts have 4 GB of RAM in total. The PHP memory_limit applies to each PHP process, not to your whole account, so several visitors at once each get their own share. Setting it very high doesn’t make a site faster. Most WordPress sites run well on 256M. For speed, see how to make WordPress faster.
Still stuck? Open a support ticket and we’ll help.
WP Toolkit, staging, backups every six hours and free migration of your site.