← Back to blog

How to Increase the WordPress Memory Limit Safely

Understand WordPress and PHP memory limits, choose an appropriate value, and apply the correct configuration without treating memory as a performance cure.

A WordPress memory error means a PHP request used more memory than it was allowed to allocate. Increasing the limit can resolve legitimate failures during updates, imports, image processing, page-builder editing, or other demanding tasks. It should be done carefully: the effective limit may be controlled by WordPress, PHP, the web server, or your hosting provider.

Before changing configuration files, keep a recoverable backup and record the original value. More memory can prevent exhaustion errors, but it does not fix inefficient code, plugin conflicts, or slow database queries.

What is the WordPress memory limit?

PHP’s memory_limit sets the maximum memory a single PHP process may allocate. WordPress also defines constants that request memory limits for normal frontend operations and higher-memory administrative tasks. The value that actually applies is constrained by the server: WordPress cannot grant itself more memory than the hosting environment permits.

A common exhaustion message looks like this:

Allowed memory size of 134217728 bytes exhausted

The byte count helps identify the limit reached. It does not, by itself, identify which plugin, theme, or operation consumed the memory. The file and line named in the error are where allocation failed, not necessarily the root cause.

How to check your current WordPress memory limit

In the WordPress dashboard, open Tools → Site Health → Info. Expand the Server section and look for the PHP memory limit. Depending on the WordPress version and hosting setup, Site Health may also show related PHP settings.

Some hosts expose PHP configuration in their control panel, while page builders and system-information screens may report their own view of the limit. If values disagree, confirm the setting with your host. Command-line and web requests can also load different PHP configurations, so a CLI value is not always the one serving WordPress pages.

How much WordPress memory do you need?

There is no universal requirement. A small site with a lightweight theme and few plugins may work within 64 or 128 MB. Many general WordPress sites use 128–256 MB. Elementor, WooCommerce, large imports, multilingual plugins, or image-heavy administrative tasks may benefit from 256–512 MB.

Treat these as general starting points, not guarantees. If a request consumes hundreds of megabytes unexpectedly, raising the ceiling repeatedly can hide a plugin bug or unbounded operation. Check logs, reproduce the task, and review recent changes.

Increase WordPress memory using wp-config.php

Edit wp-config.php in the WordPress root directory. Add the constants before the line that says to stop editing:

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

WP_MEMORY_LIMIT is the amount WordPress requests for normal operations. WP_MAX_MEMORY_LIMIT is the higher amount WordPress may request for administration tasks such as updates and image processing. The maximum constant is not permission to exceed the server’s PHP limit.

Do not add duplicate definitions. If either constant already exists, edit its value rather than adding a second copy. Use straight quotation marks and retain the semicolons. A PHP syntax error in wp-config.php can make the site unavailable until the file is corrected.

Need the right configuration snippet?

Choose a memory value and configuration file with the free WPToolix generator. It produces the relevant WordPress or PHP directive and reminds you where it belongs.

Increase PHP memory using php.ini

If you control the active PHP configuration, set memory_limit in php.ini:

memory_limit = 256M

The location of the active file varies by server, PHP version, and execution mode. Shared hosting may provide a PHP settings panel instead of direct access. PHP-FPM or the web server may need a reload before a system-level change takes effect; on managed hosting, ask support rather than restarting services without a maintenance plan.

Increase memory using .user.ini

On hosts that support per-directory PHP configuration, create or edit .user.ini in the WordPress root and add:

memory_limit = 256M

Changes to .user.ini can be cached, so they may not appear immediately. The host can disable this mechanism, restrict which directives are allowed, or enforce a lower maximum. Confirm the result in Site Health after waiting for the provider’s documented refresh interval.

Increase memory using .htaccess

On some Apache setups where PHP runs in a compatible mode, this directive can work in the WordPress .htaccess file:

php_value memory_limit 256M

This method is not portable. PHP-FPM and many managed or shared hosting environments do not allow php_value directives in .htaccess. Adding one where it is unsupported can cause an HTTP 500 Internal Server Error.

Back up the file first and keep access through the hosting file manager or SFTP. If a 500 error appears immediately, restore the previous .htaccess and use a hosting-supported method. Nginx does not use .htaccess.

Generate the correct WordPress memory configuration

The WordPress memory configuration generator can build snippets for wp-config.php, php.ini, .user.ini, or supported .htaccess environments. Select the file you can edit and a reasonable value, copy the result, then compare it with any existing directive before making changes.

The generator produces syntax; it cannot override the provider’s server-level cap. After applying a snippet, verify the effective value and repeat the operation that produced the original error.

Why WP_MEMORY_LIMIT sometimes does not work

  • The host enforces a lower PHP memory limit.
  • The constant was added after WordPress had already loaded relevant configuration.
  • A duplicate definition keeps the earlier value.
  • The edited file belongs to a different WordPress installation or environment.
  • PHP-FPM pool, container, or platform policies impose another cap.
  • The process is failing because of a timeout, disk issue, request-size rule, or fatal error rather than memory.
  • A plugin consumes the newly available memory and reaches the higher limit again.

If WordPress reports a lower value after a correct edit, consult the host’s documentation or support. On managed platforms, the control-panel value may be the only supported route.

Does increasing memory make WordPress faster?

Not automatically. A request that already completes within its allocation does not become faster merely because the ceiling is higher. More memory can allow an operation that previously failed to finish, which may feel like an improvement, but it is not a general performance optimization.

WordPress speed depends on hosting resources, caching, database work, PHP execution, network latency, images, scripts, and plugin behavior. Address the actual bottleneck. An excessive memory setting can also allow several concurrent PHP workers to consume more server RAM, so the value should match the workload and hosting capacity.

A safe memory-limit change checklist

  1. Record the current effective value in Site Health and copy the exact error message.
  2. Back up the configuration file before editing it.
  3. Choose one supported configuration method instead of adding the same directive to several files.
  4. Use a modest value that fits the workload and hosting plan.
  5. Check for an existing constant or directive and edit it rather than creating a duplicate.
  6. Save with plain-text syntax and correct quotation marks.
  7. Reload Site Health to verify the effective limit.
  8. Repeat the failed operation while watching the relevant error log.
  9. Restore the backup if the site returns a syntax error or HTTP 500 response.

If the operation still exhausts the new limit, stop raising it automatically. Disable recent changes on staging, check whether the failure follows a particular plugin or dataset, and ask the host to confirm process-level restrictions. A controlled comparison is more useful than an arbitrarily large number.

Frequently asked questions

Is 256 MB enough for WordPress?

It is a reasonable value for many sites, but plugin-heavy stores, builders, imports, and administrative jobs may need more. Measure the actual workload and respect the hosting limit.

Is 512 MB safe?

It is commonly available on capable hosting, but it is not necessary for every site. The server needs enough RAM for concurrent workers, and a high limit should not replace investigation of abnormal memory use.

Should WP_MAX_MEMORY_LIMIT be higher than WP_MEMORY_LIMIT?

It often is because administrative tasks can be heavier than frontend requests. Both values remain subject to the server’s effective PHP limit.

What should I do after a 500 error from .htaccess?

Restore the backup or remove the unsupported php_value line through SFTP or the hosting file manager. Then use wp-config.php, .user.ini, the host’s PHP panel, or support guidance.

Can a plugin cause memory exhaustion?

Yes. A demanding operation, plugin conflict, repeated query, large dataset, or code defect can consume excessive memory. Raising the limit may reveal the underlying problem rather than solve it.

WPToolix also provides other free WordPress and developer tools for common configuration and troubleshooting tasks.