DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk10 min

How to Increase the WordPress Memory Limit (and Fix “Allowed Memory Size Exhausted”)

Learn which WordPress memory constants to set, where to place them, how PHP and hosting limits affect the result, and how to fix persistent “Allowed memory size exhausted” errors.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To increase WordPress memory, raise the WordPress request in wp-config.php and, when necessary, raise PHP’s server-level memory_limit. Add WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT before WordPress loads wp-settings.php, then verify the effective value in Tools → Site Health → Info → Server. If the value does not change, your host is probably enforcing a lower PHP ceiling; a larger WordPress constant cannot bypass it.

What the WordPress memory limit controls

WordPress runs on PHP, and every PHP request has a maximum amount of memory it may allocate. The limit protects a server from one request consuming all available RAM. A page builder, plugin update, database import, image-generation job, backup, or large administrative screen can exceed that allowance and produce an error such as Allowed memory size of 134217728 bytes exhausted.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

There are two related WordPress constants:

Constant Used for What it does Documented default
WP_MEMORY_LIMIT Normal frontend requests and general WordPress execution Requests a PHP memory allowance for those requests 40M on a single-site installation; 64M on Multisite
WP_MAX_MEMORY_LIMIT Administration and other backend-intensive work Requests a higher allowance for dashboard operations 256M for administration

The figures are WordPress’s documented defaults, not promises that PHP or your hosting plan will grant those amounts. The actual ceiling is the PHP memory_limit directive. A WordPress constant can ask for a value up to that ceiling; it cannot force PHP to exceed a limit imposed by the server.

Choose the right target before editing files

There is no universal “correct” number. Use the smallest value that allows the operation to complete reliably, and increase it in measured steps. A simple site that only serves posts may need far less than a site running a visual editor, multilingual catalog, image optimization, and scheduled imports.

Workload or symptom Practical starting point Why it may need more
Lightweight brochure or blog site 128M for normal requests Provides headroom above the 40M single-site default without making a large assumption
Dashboard updates, editors, or moderate plugin work 128M frontend and 256M administration Backend screens and updates often load more code at once
Large imports, image manipulation, or complex page builders Start at 256M where the host permits it These jobs can hold several large objects in memory simultaneously
Very large or concurrent jobs Measure the failing process and size the limit with your host Blindly choosing 512M or more can hide a runaway task and consume shared resources

These are starting points, not guarantees. A plugin can fail at 256M because of an inefficient operation, while another site can run the same feature at 128M. If a failure persists after a reasonable increase, investigate the workload rather than increasing the number indefinitely.

Back up and locate the correct wp-config.php

Make a copy of wp-config.php before changing it. A syntax error in this file can take the site offline, so keep the original available through your host’s file manager, SFTP, or version-control process.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The file is normally in the WordPress root directory—the directory containing folders such as wp-admin, wp-includes, and wp-content. Some installations keep wp-config.php one directory above the public web root, which WordPress also supports. Edit the file belonging to the site that is failing, not a copy in a backup or staging directory.

Method 1: set the WordPress constants in wp-config.php

This is the first method to try because it is specific to WordPress and does not require server-level access.

  1. Open the backed-up wp-config.php in a plain-text editor.
  2. Find the line that loads the WordPress settings: require_once ABSPATH . 'wp-settings.php';.
  3. Insert only the constants you need immediately before that line. For example:
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );
  1. Save the file as plain text and upload it to the same location, preserving its name and permissions.
  2. Open the operation that previously failed, or continue to the verification step below.

The placement matters. Defining the constants after the require_once line is too late for WordPress’s normal initialization. Keep the code above that line and outside another function or conditional block.

Use one definition for each constant. If the file already contains a definition, edit its value instead of adding a second one. Duplicate definitions can generate notices, and the first value loaded may not be the one you intended.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The values are written with a unit suffix such as M for megabytes. Use normal PHP syntax and straight quotes. Do not paste the code into the WordPress editor, a page, or a plugin settings field; it belongs in the server-side configuration file.

When to set one constant or both

  • Set WP_MEMORY_LIMIT when normal page loads, REST requests, or frontend plugin code run out of memory.
  • Set WP_MAX_MEMORY_LIMIT when the dashboard, plugin/theme updates, media processing, or another administrative task is the failing operation.
  • Set both when the site has failures in both areas and the host permits the requested ceiling.

For many sites, 128M for frontend requests and 256M for administration is a sensible test configuration. Those values are examples, not a requirement to use them on every installation.

Verify the effective value in WordPress

After saving the file, check what PHP and WordPress actually received:

  1. Sign in to the WordPress dashboard.
  2. Open Tools → Site Health.
  3. Select the Info tab, expand Server, and inspect the listed PHP memory limit and related server values.
  4. Repeat the operation that failed, preferably with the same account, file, import, or image that triggered the error.

The value shown there is more useful than the number typed into wp-config.php. If it remains lower, the PHP configuration is taking precedence or the host is blocking the request. You can also ask the host for the PHP information page or the effective value for the specific PHP handler serving the site.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Method 2: raise PHP’s server-level memory_limit

When a WordPress constant does not change the effective value, inspect the PHP configuration layer. The memory_limit directive in php.ini is the maximum memory PHP is allowed to use per page render. Depending on the hosting stack, an administrator may also permit a per-directory .user.ini file or an Apache .htaccess override.

Edit php.ini when you control PHP

Find the php.ini file used by the PHP process serving the site, then set a value such as:

memory_limit = 300M

The exact file and reload procedure depend on the operating system, PHP version, web server, and handler. A command-line PHP configuration can differ from the configuration used by the web server, so verify through Site Health or the host’s PHP information rather than assuming the change applies to web requests. A service reload or restart may be required, and shared hosting commonly prevents customers from editing the global file.

Use .user.ini where the host supports it

Some PHP-FPM and FastCGI configurations allow a site-level .user.ini file in the document root. The syntax is the same directive format:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
memory_limit = 300M

This option is not enabled on every server, and PHP may cache user-INI files for a period before rereading them. Ask the host whether the file is supported, where it must be placed, and how long changes take to apply. If the effective value does not change, remove the unsupported override and use the provider’s documented method instead.

Use .htaccess only on compatible Apache setups

On an Apache configuration that permits PHP values in .htaccess, the equivalent directive is:

php_value memory_limit 300M

This syntax is handler-specific. It can trigger an HTTP 500 error when PHP runs through a handler that disallows php_value, such as some PHP-FPM arrangements. Download a copy of .htaccess first, add the directive carefully, and test the site immediately. If the site returns a 500 error, restore the backup or remove the line, then use php.ini, .user.ini, or host support.

When the host controls the ceiling

Shared hosts may deliberately block changes to memory_limit, or enforce a plan-level maximum. In that situation, WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT can request more memory but cannot override the server policy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Contact hosting support with concrete information:

  • The domain or account and the PHP version serving it.
  • The current effective memory limit shown in Tools → Site Health → Info → Server.
  • The requested PHP value and whether it is for frontend requests, administration, or one particular job.
  • The exact error text, timestamp, URL or task that failed, and whether the failure occurs consistently.

Ask whether the limit can be raised for the site or account, which configuration file or control panel setting is authoritative, and whether a PHP worker restart is needed. If the plan has a hard cap, the practical alternatives are reducing the workload, splitting the job, or moving to an environment with a higher permitted limit.

Understand what changing the memory limit does not change

Memory and upload-size settings solve different problems. post_max_size controls the maximum size of an HTTP POST body, while upload_max_filesize limits an individual uploaded file. Increasing either upload setting does not increase PHP’s memory allowance, and increasing memory does not automatically permit larger uploads. Configure those directives separately when an upload is rejected for size rather than memory.

Likewise, a higher limit does not add physical RAM to the server. On a shared plan, several PHP workers may run at once; raising the per-request value can increase total resource pressure. Choose a value the host explicitly supports and monitor whether failures, slow requests, or worker termination continue.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Diagnose “Allowed memory size exhausted” after an increase

The fatal error identifies the allocation that failed, but it does not prove that the last function named in the message is the original cause. Use a controlled troubleshooting sequence.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

1. Confirm the effective ceiling and the failing context

  • Record the memory limit shown in Site Health.
  • Note whether the failure is on the frontend, in the dashboard, during a scheduled task, or through an API request.
  • Check whether the error affects every request or only one page, post, import file, image, or user action.

A backend-only failure points toward WP_MAX_MEMORY_LIMIT or an administrative workload; a frontend-only failure points toward WP_MEMORY_LIMIT or code executed during page rendering.

2. Isolate plugins and themes

A plugin or theme can allocate excessive memory, create an unbounded loop, load a very large dataset, or conflict with another component. If you can still reach the dashboard, deactivate recently added or updated components one at a time and retest. If the dashboard is unavailable, use the host’s file manager or SFTP to rename the suspected plugin directory temporarily, or ask the host to disable plugins safely. Switch to a standard theme for a controlled test when the theme is implicated. Restore components one at a time after identifying the trigger.

3. Break large imports and batch operations into smaller jobs

Import tools often build a complete batch in memory. Reduce the number of records per batch, split a large file, process taxonomy or media separately, and avoid running multiple imports simultaneously. If the tool offers a command-line or background mode, follow its documentation; changing the web request limit alone may not make an oversized batch safe.

4. Review image-processing tasks

Creating thumbnails or converting a high-resolution image can require several in-memory representations of the source and destination. Test with a smaller image, process files in batches, and inspect image-optimization or thumbnail plugins for configuration that generates unnecessary sizes. A single unusually large image can fail even when ordinary uploads succeed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Inspect logs and scheduled work

Check PHP error logs, the web server log, and the WordPress debugging log if it is enabled. Look for the first recurring component in the stack trace, not only the final “memory exhausted” line. Review cron events and queue workers: a task that runs in the background may fail without an obvious browser error and then repeat indefinitely.

6. Replace or report a reproducible defect

If one component still exhausts memory at a host-approved limit while the rest of the site is healthy, treat it as a workload or software defect. Reproduce it on a staging copy, record the smallest input that fails, and report those details to the component’s maintainer. Keeping the limit permanently high can conceal the defect and make every PHP worker more expensive.

Common configuration mistakes

  • Putting the constants after the loader: the definitions must appear before require_once ABSPATH . 'wp-settings.php';.
  • Editing the wrong installation: confirm the path and domain before saving a file.
  • Adding duplicate definitions: edit the existing line so there is one value per constant.
  • Expecting WordPress to override PHP: a host-enforced memory_limit remains the ceiling.
  • Using invalid PHP syntax: keep the semicolon, quotes, spelling, and unit suffix exactly correct.
  • Assuming every .htaccess accepts php_value: incompatible handlers can produce a 500 error.
  • Confusing upload errors with memory errors: check post_max_size and upload_max_filesize separately.
  • Raising the value without testing: confirm the effective limit, rerun the failed operation, and watch for a repeatable trigger.

A practical decision path

  1. If the error is occasional and tied to a known admin task, set the appropriate WordPress constant before wp-settings.php, verify it, and retry.
  2. If Site Health still shows the old value, inspect the PHP configuration or ask the host which layer controls it.
  3. If the host raises the ceiling and the same operation still fails, reduce the batch, image size, or dataset and isolate plugins or themes.
  4. If normal requests remain stable but one component repeatedly consumes the allowance, fix or replace that component instead of continuing to raise the limit.
  5. After recovery, keep the lowest host-approved value that completes the workload and document the setting for future maintenance.

What a successful fix looks like

A successful change has three parts: the requested WordPress constant is placed correctly, the effective PHP value confirms that the host accepted it, and the original operation completes without creating a new recurring resource problem. If any one of those is missing, the number in wp-config.php is only a request—not proof that the site has more usable memory.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.