Increase WordPress Memory Limit & Fix Allowed Memory Size Exhausted
In this article
Running into the "Allowed memory size of X bytes exhausted" error in WordPress means your site's PHP memory limit is too low for the task at hand. This guide shows you several safe ways to increase that limit, from simple plugin tweaks to editing core configuration files, so you can get your site back up and running quickly.
What You'll Need
- Access to your WordPress admin dashboard (for the plugin method).
- FTP credentials or a file manager in your hosting control panel (for editing files).
- A code editor like Notepad++ or a plain text editor (avoid Word or rich text editors).
Step-by-Step
Method 1: Increase Memory Limit via wp-config.php (Most Common)
- Back up your site. Before editing any core file, download a full backup of your WordPress files and database. Most hosts offer a one-click backup in cPanel or similar.
- Locate wp-config.php. Connect to your server via FTP or open the file manager in your hosting control panel. This file is in the root folder where WordPress is installed (often
public_html). - Open wp-config.php in a text editor. Look for the line that says
/* That's all, stop editing! Happy publishing. */. - Add the memory limit line. Just above that line, insert the following:
define('WP_MEMORY_LIMIT', '256M');This sets WordPress to use 256MB of memory. You can replace256Mwith512Mif you need more, but start with 256M. - Save and upload. Save the file and upload it back to your server, overwriting the original. If you used the file manager, just save the changes.
- Check the new limit. Go to Tools → Site Health in your WordPress admin. Under the "Info" tab, look for "PHP Memory Limit" under the "Server" section. It should now show the new value.
Method 2: Increase Memory Limit via php.ini (For Advanced Users)
- Find or create php.ini. In your site's root folder (same place as wp-config.php), look for a file named
php.ini. If it doesn't exist, create a new file with that name. - Edit or add the memory_limit directive. Open the file and add or modify this line:
memory_limit = 256M
Save the file. - Verify the change. Use the Site Health check as above to confirm the new limit is active. If it doesn't change, your host may not allow php.ini overrides—try the wp-config.php method instead.
Method 3: Increase Memory Limit via .htaccess (Shared Hosting)
- Locate .htaccess. In your site's root folder, find the file named
.htaccess. If you don't see it, make sure your FTP client shows hidden files. - Add a PHP value line. At the top of the file, add:
php_value memory_limit 256M
Save and upload the file. - Note: This method only works if your host allows
php_valuedirectives in .htaccess. If you get a 500 error, remove the line immediately and use another method.
Method 4: Increase Memory Limit via a Plugin (Easiest)
- Install a memory limit plugin. From your WordPress admin, go to Plugins → Add New and search for "WP Memory Limit". Install and activate a reputable one.
- Set the limit. Go to Settings → WP Memory Limit and choose a value like 256M. Save your changes.
- Verify. Check Site Health to confirm the new limit is applied.
Common Mistakes
- Editing the wrong file. Make sure you're editing the wp-config.php in your WordPress root, not a subfolder or a different site.
- Using a rich text editor. Word or Google Docs can add invisible characters that break the PHP code. Always use a plain text editor.
- Setting the limit too low. 64M or 128M may not be enough for modern themes and plugins. Start at 256M.
- Forgetting to save/upload. If you edit locally, you must upload the file back to the server. If you edit in the file manager, click "Save" before leaving.
- Not backing up first. A syntax error in wp-config.php can make your entire site inaccessible. Always have a backup ready.
Tips
- Start with 256M. This is enough for most sites. Only go higher if you're running heavy plugins or a large WooCommerce store.
- Check your host's limits. Some shared hosts cap the maximum memory you can set. If 256M doesn't work, try 128M or contact support.
- Use a staging site. If you're unsure, test the change on a staging copy first to avoid breaking your live site.
- Keep a log of changes. Note what you changed and when, so you can revert if needed.
Troubleshooting
- The error still appears after increasing the limit. First, verify the new limit is actually active via Site Health. If it shows the old value, your host may be overriding your settings. Try a different method (e.g., if you used wp-config.php, try php.ini).
- Your site shows a 500 Internal Server Error after editing. This usually means a syntax error. Revert to your backup or remove the line you added, then re-upload the original file.
- You can't access wp-admin at all. If you locked yourself out, use FTP or your host's file manager to remove or comment out the line you added. You can also rename the plugin folder via FTP to disable all plugins temporarily.
- The .htaccess method caused an error. Some hosts block
php_valuedirectives. Remove the line immediately and use the wp-config.php method instead. - Memory limit is increased but the error persists. The error may be caused by a specific plugin or theme. Try disabling all plugins (via FTP, rename the
pluginsfolder toplugins_off) and switch to a default theme (via FTP, rename the active theme folder) to isolate the culprit.
Frequently Asked Questions
What is the default WordPress memory limit?
WordPress defaults to 40MB for single sites and 64MB for multisite networks. Many hosts set higher limits, but the error appears when your site needs more than what's allocated.
What is a good memory limit for WordPress?
256MB is a safe starting point for most sites. If you run heavy page builders, caching plugins, or a large WooCommerce store, 512MB may be needed.
Can increasing memory limit slow down my site?
No, it doesn't slow down your site. It just allows PHP to use more server memory when needed. However, if your server has limited RAM, setting a very high limit could affect other sites on the same server.
Is it safe to increase the memory limit?
Yes, it's a standard configuration change. As long as you follow the correct file editing procedures and don't set an absurdly high value (like 1G) on a shared host, it's safe.
What if my host doesn't allow changing the memory limit?
Some managed hosts restrict this. You can try the plugin method, but if that fails, contact your host's support and ask them to increase the PHP memory limit for your account.
Will increasing memory limit fix all "allowed memory size" errors?
It fixes the error when the limit is simply too low. However, if a specific plugin has a memory leak or is poorly coded, the error may appear again even with a higher limit. In that case, you need to fix or replace the problematic plugin.