The WordPress memory exhausted error occurs when your site’s PHP processes exceed the allocated memory limit, causing a fatal error and site downtime. This typically stems from resource-heavy plugins, inefficient themes, or restrictive server settings. The good news? You can fix this yourself with basic file edits and systematic troubleshooting. This guide walks you through five reliable solutions, starting with the simplest memory increase and ending with professional help if needed.
What You Need Before You Start
Before making any changes, ensure you have the necessary access and safeguards in place. Rushing into file edits without preparation can worsen the problem or cause additional errors.
Backup Your Entire Site
Create a full backup of your WordPress files and database using a plugin like UpdraftPlus or your host’s backup tool. This safety net allows you to restore your site if an edit goes wrong.
Access Your Server Files
You’ll need FTP credentials (like FileZilla) or access to your hosting provider’s file manager (cPanel, Plesk, or custom dashboard). This lets you edit critical WordPress files.
Note Your Current Memory Limit
Check your existing PHP memory limit by going to WordPress Dashboard > Tools > Site Health > Info > Server. Look for ‘PHP memory limit.’ This gives you a baseline for increases.
Step 1: Increase Memory Limit via wp-config.php
The wp-config.php file is WordPress’s core configuration file. Adding a memory limit definition here often resolves the error quickly, as it overrides default server settings.
Locate and Edit wp-config.php
Using FTP or your file manager, navigate to your WordPress root directory (public_html or www). Find wp-config.php, download it, and open it in a text editor.
Add the Memory Limit Code
Just before the line that says ‘/* That’s all, stop editing! Happy publishing. */’, add: define(‘WP_MEMORY_LIMIT’, ‘256M’);. Save the file and re-upload it, overwriting the old version.
Test Your Site
Refresh your WordPress site. If the error disappears, the fix worked. If not, proceed to the next step. Note: Some hosts cap memory limits; 256M is a safe starting point.
Step 2: Modify php.ini to Raise Memory Limit
If wp-config.php didn’t work, your server’s php.ini file controls PHP settings directly. Editing this can lift restrictions that WordPress cannot override.
Find Your php.ini File
In your hosting file manager, look for php.ini in the root directory or a folder like /php or /etc. If you don’t see it, create a new file named php.ini in your WordPress root.
Edit the Memory Limit
Open php.ini and find the line ‘memory_limit = XM’. Change X to 256 or higher (e.g., 256M or 512M). If the line doesn’t exist, add: memory_limit = 256M.
Restart PHP (If Required)
Some hosts require you to restart PHP via your control panel (look for ‘PHP Settings’ or ‘Select PHP Version’) for changes to take effect. If unsure, contact your host.
Step 3: Adjust .htaccess for Memory Allocation
For Apache servers, the .htaccess file can sometimes override PHP settings. This method is less common but worth trying if previous steps failed.
Edit .htaccess
In your WordPress root directory, locate .htaccess (it’s a hidden file—enable ‘show hidden files’ in your file manager). Open it for editing.
Add the PHP Value Directive
At the top of the file, add: php_value memory_limit 256M. Save and re-upload. Note: This may cause a 500 error on some hosts (like Nginx or restricted shared hosting). If that happens, remove the line immediately.
Step 4: Identify and Deactivate Problematic Plugins or Themes
Even with high memory limits, a poorly coded plugin or theme can consume excessive resources. Isolating the culprit is crucial for a long-term fix.
Enable Debugging Mode
In wp-config.php, add define(‘WP_DEBUG’, true); just above the memory limit line. This logs errors to /wp-content/debug.log, helping identify memory-hungry components.
Deactivate All Plugins
Via FTP, rename the /wp-content/plugins folder to /plugins_old. This deactivates all plugins instantly. Check if the error resolves. If yes, rename it back and reactivate plugins one by one, testing after each to find the offender.
Switch to a Default Theme
If plugins aren’t the issue, your theme might be. Temporarily switch to a default WordPress theme (like Twenty Twenty-Four) by renaming your theme’s folder in /wp-content/themes. WordPress will fall back to a default theme.
Step 5: Contact Your Hosting Provider for Assistance
If none of the above works, your hosting environment may impose hard limits or have server-level constraints. Your host’s support team can provide solutions tailored to your plan.
Gather Error Details
Note the exact error message (e.g., ‘Allowed memory size of X bytes exhausted’), your site URL, and the steps you’ve already tried. Screenshots help.
Ask Specific Questions
Request: ‘Can you increase my PHP memory limit to 256M or higher?’ or ‘What is the maximum memory limit for my hosting plan?’ If you’re on shared hosting, they may suggest upgrading to a VPS or optimized WordPress plan.
Consider Long-Term Solutions
Ask about server-side caching (like Redis or Memcached), PHP version updates (use PHP 8.0+), or managed WordPress hosting, which often includes optimized memory settings.
Common Mistakes to Avoid
Avoid these pitfalls that can turn a simple fix into a major headache:
Skipping the Backup
Never edit core files without a recent backup. A single syntax error in wp-config.php can lock you out of your site entirely.
Editing the Wrong Files
Double-check file locations. Editing a php.ini in a subfolder instead of the root may have no effect. Use the Site Health tool to confirm your PHP configuration path.
Ignoring Host Restrictions
Some shared hosts ignore php.ini or .htaccess memory directives. If you see no change after editing, your host likely overrides these files.
Forgetting to Test After Each Step
Always clear your browser cache and test after each change. If an edit causes a white screen, revert immediately using your backup or FTP.
Conclusion
Fixing the WordPress memory exhausted error is usually a matter of methodically increasing your PHP memory limit and eliminating resource-intensive plugins or themes. Start with the wp-config.php edit—it’s the safest and most effective first step. If the problem persists, work through each solution in order. Remember, a well-optimized site with efficient plugins needs less memory. If you’ve followed this guide and still face issues, your hosting environment may need a professional touch. Feel free to reach out to our support team for personalized assistance—we’re here to help you get your site running smoothly again.
Frequently Asked Questions
What if I don't have access to wp-config.php or php.ini?
Some managed WordPress hosts restrict direct file access. In that case, contact support immediately and request a memory limit increase. They can adjust server settings for you.
Will increasing the memory limit slow down my website?
No. A higher memory limit allows WordPress to handle more processes efficiently. However, if you constantly need very high limits (e.g., 512M+), it often indicates a plugin, theme, or database query that needs optimization.
Is 256M always enough? What if I need more?
256M suits most small to medium sites. Large e-commerce or membership sites with heavy plugins may need 512M. If you still hit limits after optimization, consider upgrading your hosting plan for more resources.
Can this error damage my website or data?
The error itself doesn’t corrupt data—it simply halts processes to prevent server overload. However, prolonged downtime can affect SEO and user trust. Fixing it promptly is essential for site health and reliability.