When your WordPress site runs out of memory, it usually shows a white screen, an error like “Allowed memory size of X bytes exhausted,” or pages that suddenly stop loading. This guide walks you through the most common fixes—from increasing PHP memory limits to optimizing your database—so you can get your site back online and prevent future crashes.
What You’ll Need
- Access to your hosting control panel (cPanel, Plesk, or a custom panel)
- FTP credentials or a file manager in your hosting panel
- Ability to edit files like
wp-config.phpand.htaccess - If you don’t have file access, contact your host’s support—they can often make the changes for you
Step-by-Step
- Confirm the error. Check your WordPress debug log (via
wp-content/debug.log) or the server error log to see the exact memory limit and which script is failing. This tells you if it’s a plugin, theme, or core issue. - Increase the PHP memory limit. The quickest fix is to edit
wp-config.phpand add this line before the “That’s all, stop editing!” comment:define('WP_MEMORY_LIMIT', '256M');
For sites with heavy plugins or a large media library, try 512M. If you can’t edit files, add this to your.htaccess(Apache) orphp.ini(if you have access):php_value memory_limit 256M(Apache) ormemory_limit = 256M(php.ini). - Check for plugin or theme bloat. Temporarily deactivate all plugins via the admin dashboard (or by renaming the
wp-content/pluginsfolder via FTP). If the site loads, reactivate plugins one by one to find the culprit. Switch to a default theme (like Twenty Twenty-Four) to rule out a theme issue. - Optimize your database. Run a plugin like WP-Optimize or use phpMyAdmin to run
OPTIMIZE TABLEon your WordPress tables. This clears transient options and post revisions that can bloat memory usage. - Limit post revisions. Add this to
wp-config.phpto keep only the latest 5 revisions per post:define('WP_POST_REVISIONS', 5); - Increase server memory (if you have root access). Edit
php.iniand setmemory_limit = 512M, then restart PHP (e.g.,sudo systemctl restart php8.1-fpm). If you’re on shared hosting, ask your host to raise the limit. - Enable caching. A caching plugin (like W3 Total Cache or WP Super Cache) reduces PHP memory usage by serving static pages. Configure page caching and object caching if available.
- Update everything. Ensure WordPress core, all themes, and plugins are up to date. Outdated code can have memory leaks.
Common Mistakes
- Setting the memory limit too high. A limit of 1G or more can cause server instability. Stick to 256M–512M unless you have a dedicated server.
- Editing the wrong file. Make sure you’re editing
wp-config.phpin the root of your WordPress installation, not a subfolder or a backup. - Forgetting to save and clear caches. After editing, clear any server-side caches (like OPcache) or your browser cache to see the change.
- Ignoring the actual cause. Simply raising the limit masks the problem. A poorly coded plugin will still eat memory, just more slowly.
- Deactivating all plugins without testing. If you deactivate all and the site works, you must identify the specific plugin—don’t leave them all off.
Tips
- Monitor your memory usage with a plugin like Query Monitor to see which scripts use the most.
- Use a CDN to offload static assets, reducing PHP load.
- Regularly delete spam comments and old post revisions to keep the database lean.
- Consider upgrading your hosting plan if you consistently hit limits—shared hosting often has low caps.
- If you’re not comfortable editing files, most hosts offer a “PHP Settings” section in the control panel where you can change the memory limit.
Troubleshooting
If the steps above don’t resolve the issue:
- Check for a corrupted
.htaccess. Rename it to.htaccess.bakand see if the site loads. If it does, go to Settings → Permalinks and click “Save Changes” to regenerate it. - Look for a malware infection. A hacked site can consume memory with background processes. Scan with a security plugin or check for unknown files in
wp-content. - Check server logs for repeated errors. Look for “out of memory” or “segfault” messages—these indicate PHP is crashing.
- Try increasing the memory limit via a mu-plugin. Create a file
wp-content/mu-plugins/memory.phpwithini_set('memory_limit', '256M');—this can override some hosting restrictions. - If nothing works, contact your host. They can check server-level settings and may need to increase the memory limit in the PHP-FPM pool configuration.
Frequently Asked Questions
What is the default WordPress memory limit?
WordPress defaults to 40M for single sites and 64M for multisite, but many hosts set it higher (e.g., 128M or 256M).
How do I check my current memory limit?
Install a plugin like “WP Memory Usage” or add phpinfo(); to a test file and view it in your browser. Or check the error message if you’re getting one.
Is it safe to set memory limit to 512M?
Yes, on most modern hosting it’s safe. However, if your server has limited RAM (e.g., 1GB), a high limit can cause other sites to slow down. Start with 256M and increase only if needed.
Why does my site still crash after increasing the limit?
There may be a plugin with a memory leak or a corrupted database. Try deactivating plugins, optimizing the database, and checking for errors in the debug log.
Can I increase memory limit without file access?
Yes, you can add a line to your .htaccess (if Apache) or use a plugin like “WP Memory Limit” that modifies wp-config.php for you. If neither works, ask your host.
Will increasing memory limit fix all crashes?
No. It fixes errors caused by hitting the PHP memory cap, but crashes can also be due to CPU limits, database timeouts, or server resource exhaustion. Monitor your site’s health after the fix.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Turn Off Backup Encryption in iTunes?
- Campus Tech Innovation Hubs: What They Are
- Poco C51 Airtel Prepaid Locked Variant India?
- Jenkins vs GitHub Actions: Which CI/CD Fits Your Team?
- Shared VPS Hosting: Is It Better?
- Disk Defrag Pro: What It Does and Whether You Need It