Skip to content
ThemesIonic — home
Troubleshooting

How to Increase the WordPress Memory Limit

Raise WordPress memory in wp-config.php, verify the effective PHP limit, and use the fatal error log to find the plugin, query or import that exhausted it.

4 min read intermediate

Quick fix: if the log contains Allowed memory size ... exhausted, add WP_MEMORY_LIMIT to wp-config.php before WordPress loads, then verify the effective PHP value. Use the increase to restore service, but identify what consumed the memory so the error does not return with more traffic or data.

Back up wp-config.php before editing it.

Confirm that memory is the actual error

Look for a fatal message similar to:

Allowed memory size of 134217728 bytes exhausted
(tried to allocate 20480 bytes)

The first number is the request’s limit in bytes. The file path and stack trace help identify what was running when the allocation failed.

Do not assume every white screen, 500 error or failed upload is memory-related. Enable a private log using WordPress Debug Mode and reproduce the failure once.

Set the frontend WordPress limit

Open wp-config.php and add this above the line that loads wp-settings.php or says “stop editing”:

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

This asks WordPress to raise the PHP memory limit for normal requests when the server allows it. It does not reserve 256 MB for every visitor, but a request can consume up to that value.

Choose a value supported by the hosting plan. If the error occurred at 128M, testing 256M can confirm whether a legitimate import or image operation simply needs more headroom. Jumping straight to 1G can hide runaway code and exhaust the server under concurrency.

Set a separate admin limit when needed

Administrative operations such as updates, imports and media processing can need more memory:

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

WP_MAX_MEMORY_LIMIT applies to designated administration tasks. WordPress’s official wp-config documentation explains the two constants and warns that more memory can conceal the underlying problem.

Verify the effective PHP limit

Do not stop after saving the file. Check Tools → Site Health → Info → Server, or use WP-CLI:

wp eval 'echo ini_get( "memory_limit" ) . PHP_EOL;'

Also check what WordPress requested:

wp eval 'echo WP_MEMORY_LIMIT . PHP_EOL; echo WP_MAX_MEMORY_LIMIT . PHP_EOL;'

If PHP still reports a lower value, WordPress was not permitted to raise it.

Change the server limit when WordPress cannot

Use the host’s PHP settings panel or the configuration method appropriate to the server. A server you administer may use:

memory_limit = 256M

in php.ini or a pool-specific PHP-FPM configuration. Reload PHP-FPM when required, then verify the value from a web request—not only the command-line PHP binary, which may load a different configuration.

On managed/shared hosting, ask support to raise the limit or explain the account cap. Avoid scattering conflicting values across php.ini, .user.ini, .htaccess and wp-config.php.

Find what used the memory

Use the final fatal log entry to classify the workload:

  • a plugin path: test that plugin disabled or rolled back on staging;
  • a theme path: switch to a default theme on staging;
  • image functions: reduce source dimensions and inspect image libraries;
  • import/export: split the job into batches or run it through CLI;
  • database/query code: profile the query and result size;
  • backup/security scan: schedule it away from traffic and adjust scope;
  • repeated recursion: fix the code rather than adding memory.

Memory use often grows with products, users, menu items or autoloaded options. A task that worked on a new site can fail months later.

Watch total server capacity

A per-request limit is not the server’s total memory. Ten concurrent PHP workers each allowed 512 MB can theoretically demand far more than a small server has available.

Check PHP worker limits, database memory, object cache and operating-system headroom. If raising the limit produces server-wide swapping or killed processes, reduce concurrency and optimize the workload.

Confirm and clean up

Repeat the exact action that failed, then inspect the log. Test both frontend and wp-admin. Document the old limit, new limit and responsible component.

If the error returns at the new ceiling, stop increasing it and profile the failing process. For a generic HTTP failure without a memory message, follow the WordPress 500 error guide.

Frequently asked

There is no universal value. Use enough for the measured workload while staying within the hosting plan. 256M is a common troubleshooting request, not a requirement for every site.
WordPress can request a higher value only when the server permits it. PHP configuration, hosting policy or a lower account limit may cap the effective memory.
Not normally. It prevents a request from failing when it legitimately needs more memory. A slow plugin or inefficient query remains slow and may consume even more resources.

Related guides