Raising WP_MEMORY_LIMIT in WordPress the safe way
PrintWhen WordPress runs short of memory, you usually see a white page, a half-finished import or the message Allowed memory size of ... bytes exhausted. The fix is one line in wp-config.php. The only catch is choosing a value the server will actually honour.
The ceiling and the request
Two settings are involved:
- memory_limit belongs to PHP and is set per domain in cPanel. Think of it as the ceiling.
- WP_MEMORY_LIMIT is the share of that ceiling WordPress asks for. Out of the box it is 40M for a single site and 64M for multisite.
A WP_MEMORY_LIMIT above the PHP ceiling does nothing, so always check the ceiling first.
Check the PHP ceiling
- Sign in to cPanel and open MultiPHP INI Editor.
- Pick the domain of your site.
- Read the value of memory_limit.
WordPress can show you both numbers as well: go to Tools, then Site Health, then the Info tab. The Server section lists the PHP limit and the WordPress Constants section lists the current WP_MEMORY_LIMIT.
If the PHP limit is too low, raise it in cPanel first, within what your plan allows. See How to change php.ini settings in cPanel.
Set the WordPress value
- Open File Manager in cPanel and go to the folder of the site, normally
public_html. - Download a copy of
wp-config.phpfirst, so you can put the original back if anything goes wrong. - Right-click the file and choose Edit.
- Find the comment
That's all, stop editing!and add this line just above it:
define( 'WP_MEMORY_LIMIT', '256M' );
- Click Save Changes, then confirm under Site Health that WordPress picked up the new value.
256M covers most sites. A large store or a heavy page builder may need more, but never set it above the PHP limit.
If nothing changed
- Wrong position. Lines placed after
wp-settings.phpis loaded are never read. Keep the line above the "stop editing" comment. - Duplicate constant. The file may already define WP_MEMORY_LIMIT further up. Edit that line instead of adding a second one.
- Curly quotes. Text pasted from a word processor can turn straight apostrophes into typographic ones, which breaks PHP. Type them by hand.
Worth knowing
The admin area has its own constant, WP_MAX_MEMORY_LIMIT (256M by default). Only touch it if the error appears in wp-admin alone, for example when editing images.
Raising the PHP limit does not give your account more RAM; the total is set by your hosting plan. If the error keeps coming back, a plugin or theme is probably using far too much memory. The error log will point to it: see How to read error_log and turn off the plugin that causes an error.