Allowed memory size exhausted in WordPress – causes and solutions

This error means your site needed more memory than was available.

Every WordPress user eventually encounters a cryptic error message. Imagine activating a new plugin or uploading a large image, and suddenly you see a white screen with: “Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)”. It sounds scary, but don’t panic — this common WordPress error is usually easy to fix.

In this article I explain in plain language what “Allowed memory size exhausted” means, why it happens, and — most importantly — how to fix it yourself. I also share tips to prevent memory problems in the future.

In short: this error means your website needed more memory than it had. Below you’ll see how to increase the memory limit (via wp-config.php, .htaccess, php.ini, or cPanel) and how to avoid the issue recurring. Let’s dive in.

What does “Allowed memory size exhausted” mean?

When WordPress shows a message like “Allowed memory size of 67108864 bytes exhausted,” it simply means your site ran out of its allocated memory. Every website gets a certain amount of RAM to run PHP scripts and store data. WordPress, plus your plugins, theme, and media files, all consume memory. If your site tries to use more than allowed, PHP stops the process and you see a fatal error.

Tip: the long number in the error (for example 67108864 bytes) is the memory limit. 67108864 bytes equals 64 MB. The “tried to allocate … bytes” part tells you how much extra memory WordPress tried to use at the moment it failed.

In plain terms: this error usually happens because the PHP memory limit is too low or your site exceeds it. WordPress often defaults to 32 MB or 64 MB — fine for simple sites, but too low for heavy tasks. On growing sites with many plugins, large images, or complex themes, the limit is easily reached. This often happens when activating a heavy plugin, switching themes, or uploading a lot of media. A plugin with a memory leak or inefficient code can also suddenly consume huge RAM and trigger the error.

So the error simply means your WordPress site hit a memory wall. Fortunately, it’s clear what’s wrong (memory ran out) — and that makes the fix straightforward.

Increase the memory limit: how to fix the error

The solution is simple: give your site more memory so it doesn’t hit the limit. In practice this means increasing the PHP memory limit. There are several ways to do this depending on your hosting setup. Here are four methods:

  • Adjust via wp-config.php
  • Add a rule in .htaccess
  • Change settings in php.ini
  • Increase the limit via your hosting panel (e.g., cPanel)

Choose the method that fits your situation. If you can access site files (FTP or file manager), use wp-config.php or .htaccess. If you manage your own server or VPS, you may have access to php.ini. For most users, the hosting panel method is the easiest.

Before you start: always back up important files before editing them — especially wp-config.php and php.ini. A small typo can break your site. The changes are simple, but better safe than sorry.

Method 1: Increase PHP memory limit via wp-config.php

Image: in the WordPress configuration file wp-config.php you can increase the memory limit by adding or adjusting the WP_MEMORY_LIMIT constant. In this example it is set to 256M.

The most common method is editing wp-config.php in your WordPress root. Steps:

  1. Open wp-config.php — this file sits in the WordPress root (often /public_html). Access it via FTP (e.g., FileZilla) or your hosting file manager.
  2. Look for WP_MEMORY_LIMIT — check if a line like define('WP_MEMORY_LIMIT', '...'); already exists. If it does, you can increase the value.
  3. Add or update the line. If it doesn’t exist, add this just before “That’s all, stop editing! Happy blogging.”:
define('WP_MEMORY_LIMIT', '256M');

This sets the memory limit to 256 MB. In most cases that’s enough. If the line already exists with a lower value (e.g., 64M), raise it to 256M. You can go higher (e.g., 512M) if needed, but hosts often impose a maximum.

  1. Save the file and upload it back if needed.
  2. Retry the action that caused the error (plugin activation, upload, etc.). If the error disappears, you’ve fixed it. If not, try increasing the value further. If it still fails at high values, you may have hit your host’s maximum limit.

Note: WordPress also has an admin‑area memory limit (WP_MAX_MEMORY_LIMIT). You rarely need to change that unless the error only occurs in wp-admin.

Method 2: Increase memory limit via .htaccess

Image: example of a .htaccess file where the PHP memory limit is raised to 256M using php_value memory_limit 256M.

Another option (mainly for Apache servers with PHP as a module) is to adjust .htaccess in the WordPress root. Steps:

  1. Open the .htaccess file in the WordPress root (it’s hidden, so enable “show hidden files”). Back it up first.
  2. Scroll to the end, after the # END WordPress block.
  3. Add this line:
php_value memory_limit 256M
  1. Save and test your site again.

Note: not all hosts allow PHP overrides in .htaccess. If this causes a 500 error or has no effect, remove the line and use another method.

Method 3: Increase memory limit via php.ini (or user.ini)

On some servers (especially VPS or self‑managed hosting) you can change PHP settings directly in php.ini.

  1. Locate php.ini — this may be global or per‑site. Some hosts allow a local php.ini or .user.ini in public_html.
  2. Edit the file and find the memory_limit line (e.g., memory_limit = 64M).
  3. Increase it, for example:
memory_limit = 256M
  1. Save the file. On VPS/dedicated servers you may need to restart PHP or the web server.
  2. Test again.

If nothing changes, your host might ignore custom php.ini files in shared hosting. Use another method instead.

Method 4: Increase PHP memory limit via cPanel (hosting panel)

Many hosting providers let you change PHP settings in a control panel like cPanel or DirectAdmin. In cPanel, look for “Select PHP Version” or “MultiPHP INI Editor”.

Image: in cPanel under Software → Select PHP Version you can adjust PHP options. Here the memory_limit setting can be changed to e.g. 256M.

Steps in cPanel:

  1. Log in to cPanel and go to Software.
  2. Click Select PHP Version (or PHP Settings / MultiPHP Manager).
  3. Go to Options or Switch to PHP Options.
  4. Find memory_limit and select a higher value (e.g., 256M or 512M).
  5. Save changes and retest your site.

Other panels (Plesk, DirectAdmin, hPanel, etc.) have similar settings. If the option isn’t available, your plan may enforce a fixed limit — contact your host or consider upgrading.

What if it still doesn’t work?

If you tried everything and the error keeps coming back, one of two things is likely:

  • You’ve hit the maximum memory limit allowed by your hosting plan. In that case you’ll need an upgrade or ask the host for a higher limit.
  • Something else is wrong — for example a plugin stuck in a loop consuming memory endlessly. Try disabling plugins one by one, or check server error logs for clues.

In practice the first scenario is most common: your site has simply outgrown the resources of your hosting plan.

Tips to prevent memory errors

Prevention is better than cure. Once you’ve fixed the issue, use these best practices to avoid it recurring:

  • Clean up plugins and themes: too many or heavy plugins are the most common cause. Remove unused plugins/themes and avoid overlapping functionality.
  • Choose efficient plugins: some plugins are memory hogs. Reviews and documentation often mention this. You can also use tools like Query Monitor to see which plugins consume memory.
  • Use caching and optimization: caching plugins (WP Super Cache, W3 Total Cache, etc.) reduce PHP load by serving static pages. Optimize images and keep the database tidy.
  • Keep everything updated: updates often improve performance and reduce memory use. PHP 8.x is more efficient than older versions like PHP 5.6.
  • Monitor memory usage: hosting panels or plugins can show how much memory your site uses. If you’re always close to the limit, upgrade resources before errors happen.
  • Choose a suitable hosting plan: a site with many plugins or WooCommerce features needs more RAM than a simple blog. Repeated memory errors are a sign it’s time to upgrade.

Conclusion: fix it yourself or hand it off

The “Allowed memory size exhausted” error can be scary, but it’s usually fixed by increasing PHP memory limits. A few simple changes in wp-config.php, .htaccess, php.ini, or the hosting panel can solve it in minutes. You’ve also learned how to prevent future memory problems with smarter plugin choices, optimization, and hosting.

Done chasing slowdowns?

Performance issues tend to come back after quick fixes. Managed hosting keeps updates, caching and limits consistent.

See managed WordPress hosting