You open your site and instead of your homepage you get a white screen and one ugly line: Fatal error: Allowed memory size of 134217728 bytes exhausted. That is the wordpress allowed memory size exhausted error, and it means a single PHP request asked for more memory than your server allows. The fix is usually quick: raise the limit, then find what was eating the memory.
What the WordPress Allowed Memory Size Exhausted Error Means
Every PHP request gets a memory budget. WordPress core needs only a small slice of it, but a page build can pull in a theme, a dozen plugins, image processing, and a few heavy database queries at once. When the total crosses the limit, PHP stops the request and prints the error. The number in the message is the limit in bytes: 134217728 is 128 MB, 268435456 is 256 MB, and 536870912 is 512 MB.
The error is not proof your VPS is too small. It is proof one request needed more than the budget allowed. Sometimes the budget is simply set too low by the host or the panel. Sometimes a single plugin has a memory leak or an unbounded query, and no reasonable budget would save it.
Back up the site before you change anything, and check the latest backup actually completed.
How Much Memory WordPress Actually Needs
There is no single correct number. It depends on the theme, the plugin count, and what the site does. As a starting point, these values cover most self-hosted sites:
| Site type | Sensible memory limit |
|---|---|
| Small blog, light theme, few plugins | 128 MB |
| Business site or blog with a page builder | 256 MB |
| WooCommerce store or membership site | 256–512 MB |
| Large store with many plugins | 512 MB |
Going past 512 MB rarely helps a normal site. If WordPress still runs out at 512 MB, something is wrong with the code, not the budget. Remember the PHP limit is per request, not per site: twenty simultaneous requests at 256 MB each can still exhaust a 2 GB server.
Step 1: Increase WordPress Memory Limit in wp-config.php
The fastest way to increase wordpress memory limit for one site is the WP_MEMORY_LIMIT constant in wp-config.php. Open the file in the WordPress root directory and add this line above the comment that says /* That's all, stop editing! */:
define( 'WP_MEMORY_LIMIT', '256M' );
If your admin area also hits the error, for example when importing media or running an update, add a second line for the dashboard:
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
Save the file and reload the page. If the error returns with a higher number in the message, the new limit is active and something is still using too much memory, so keep going: a higher limit that masks a leak only delays the next crash.
One warning: WP_MEMORY_LIMIT cannot raise the limit above what PHP itself allows. If PHP is capped at 128 MB, asking WordPress for 256 MB does nothing. That is why the next step matters.
Step 2: Raise the Limit in php.ini and PHP-FPM
The php memory limit wordpress actually uses comes from the PHP configuration, not from WordPress. Find the active php.ini with php --ini, then set:
memory_limit = 256M
On a VPS running PHP-FPM behind nginx, editing php.ini alone is not always enough. Some pools set their own limit with php_admin_value[memory_limit] in the pool config, typically under /etc/php/8.4/fpm/pool.d/. A pool value overrides php.ini, so check there if your change seems to have no effect. Restart PHP-FPM after any edit (systemctl restart php8.4-fpm, adjusting the version to match your install), then confirm with php -i | grep memory_limit.
If you run several sites on one VPS, set the limit per pool rather than globally. That way a hungry site cannot take memory budgeted for the others, and you can see from the pool config which site has the higher allowance and why.
Step 3: Find the Plugin or Theme Eating Memory
With the site back online, the next job is finding what pushed memory over the edge. Start with the simplest test: deactivate all plugins, then reactivate them one at a time while reloading the page that failed. When the wordpress memory limit error comes back after one specific plugin, you have your suspect. Check whether that plugin has an update, a known issue, or a lighter alternative before you accept its appetite as normal.
Common culprits are page builders rendering large pages, backup plugins running during traffic hours, security plugins scanning every request, and import tools processing big files. A plugin is not automatically bad for using memory; the question is whether the memory matches the work. A contact form needing 200 MB is a problem. An image optimizer processing a batch of uploads is doing its job.
If the error appears only in the admin area, look at the theme too. Switch to a default theme such as Twenty Twenty-Five for a minute and reload the failing admin page. If the error disappears, the theme or its bundled plugins are involved. Our guide to finding which plugin slows down your WordPress site covers the same hunt in more detail, including timing each plugin so you can rank them by cost instead of guessing.
Also check the database. A bloated wp_options table, thousands of expired transients, or years of post revisions can turn a normal query into a heavy one. Cleaning those up often drops memory use more than any limit change, as covered in our walkthrough of shrinking a bloated WordPress database without a plugin.
Step 4: Check the Server Itself
Sometimes the site is fine and the server is the bottleneck. Run free -h and check how much RAM is actually free. If the VPS has 1 GB of RAM and MySQL, PHP-FPM, and nginx are already using most of it, raising the WordPress limit only moves the failure from PHP to the operating system, which starts killing processes instead.
Check what is using memory right now with htop or ps aux --sort=-%mem | head. A runaway PHP-FPM pool with too many children is a frequent cause: each child holds its own memory, and a busy hour can multiply a modest per-request limit into gigabytes. Tuning the pool so the child count matches the RAM available is usually the real fix, and our guide to tuning PHP-FPM pm settings for a 2 GB RAM VPS walks through the numbers. The walkthrough on finding which process is eating your VPS RAM shows how to read the output and tell a real leak from normal caching.
Check the PHP and nginx error logs too: they record the exact file and line where memory ran out. If the same file appears every time, the problem is in that code, and no limit increase will fix it for long.
When Raising the Limit Does Not Fix It
If the error survives a 512 MB limit, stop raising and start reading. The usual causes at this point are a genuine memory leak in a plugin or theme, an import or migration script loading an entire file into memory, a cron job firing too often, or a loop that never ends. The wp-config.php memory limit is a ceiling, not a cure, and a leak will climb to whatever ceiling you set.
Try the failing action with WP_DEBUG enabled and the debug log turned on, then read wp-content/debug.log for the entries just before the crash. If the error hits a fresh install with a default theme and no plugins, the problem is in the server configuration, not the site: check the PHP-FPM pool, the opcache settings, and whether another site on the same VPS is consuming the shared memory.
As a last check, compare the error against the other common WordPress failure on a VPS. If you are seeing connection errors alongside memory errors, read our guide to fixing the WordPress database connection error before assuming memory is the only problem. And if the screen is blank with no error message at all, the white screen guide covers that case, since a memory error with display errors off can present as a plain white page.
Raise the limit to get the site back, find the code that needed it, and fix the cause rather than the number.
How to Stop the Error Coming Back
Fix it once, then make it hard to recur. Keep plugins updated and remove the ones you no longer use, because every active plugin adds to every request. Schedule heavy jobs, like backups and image optimization, for low-traffic hours. Set up a simple monitor that alerts you when free memory drops, so you hear about the next spike before visitors do. And write down the limit you set and why: six months from now, a future you will want to know whether 256 MB was a measured choice or a guess made in a hurry.