The WordPress memory limit exhausted error (e.g., “Fatal error: Allowed memory size of X bytes exhausted”) can crash your site, especially when running resource-heavy plugins or themes. This frustrating issue stops your site in its tracks, but don’t worry! In this 2025 step-by-step guide, I’ll show you how to fix the WordPress memory limit error, even if you’re a beginner. With clear instructions, code snippets, and expert tools, you’ll restore your site fast. Let’s get started!
What Causes a WordPress Memory Limit Exhausted Error?
This error occurs when WordPress exceeds the allocated PHP memory, halting script execution. Common causes include:
- Low PHP Memory Limit: Default limits (e.g., 64M) are too low for modern WordPress sites.
- Resource-Heavy Plugins: Plugins like WooCommerce or page builders consume excessive memory.
- Bloated Themes: Complex themes with heavy code overload servers.
- Large Databases: Unoptimized databases strain memory during queries.
- Server Restrictions: Shared hosting often caps memory to 32M or 64M.
- Custom Code: Memory-intensive scripts in
functions.phpor custom plugins.
This guide covers 5 actionable steps to resolve the error and prevent future issues, optimized for 2025 WordPress setups.
Prerequisites
- Access to your WordPress admin panel (
yoursite.com/wp-admin) and site files (via FTP or hosting file manager, e.g., SiteGround’s cPanel). - A backup of your site (use UpdraftPlus for free, reliable backups).
- Basic WordPress knowledge (I’ll keep steps beginner-friendly!).
Note: High-memory hosting prevents this error. I recommend SiteGround for their generous resource allocations and fast support.
Step 1: Increase PHP Memory Limit in wp-config.php
The quickest fix is to increase WordPress’s memory allocation.
- Edit
wp-config.php:- Access your site’s root folder via FTP (e.g., FileZilla) or file manager.
- Open
wp-config.phpand add before/* That's all, stop editing! */:
define('WP_MEMORY_LIMIT', '256M');
Code language: JavaScript (javascript)
- Save and Upload:
- Save the file and upload it, overwriting the original.
- Test Your Site:
- Visit your site and admin panel (
yoursite.com/wp-admin). If the error is gone, this step worked.
- Visit your site and admin panel (
Why It Works: Setting WP_MEMORY_LIMIT to 256M gives WordPress enough memory to handle most tasks, resolving the error.
Pro Tip: Use Query Monitor (self-hosted) to check memory usage in the admin panel.
Step 2: Modify php.ini for Server-Wide Memory Increase
If wp-config.php doesn’t work, adjust the server’s PHP memory limit.
- Access
php.ini:- Via hosting file manager or cPanel, locate
php.ini(often inpublic_htmlor a parent folder). - If unavailable, create a
php.inifile in the root folder.
- Via hosting file manager or cPanel, locate
- Add Memory Limit:
- Add or update:
memory_limit = 256M
- Save and Test:
- Save, upload, and visit your site to confirm the error is resolved.
Alternative: Some hosts (e.g., SiteGround) allow memory adjustments via cPanel’s PHP Version Manager or PHP Variables.
Why It Works: Increasing the server’s memory limit ensures all PHP scripts, including WordPress, have sufficient resources.
Affiliate Link: SiteGround makes PHP memory adjustments easy via their dashboard.
Step 3: Optimize or Disable Heavy Plugins
Resource-intensive plugins often trigger memory limit errors.
- Audit Plugins:
- Go to Plugins > Installed Plugins and note active plugins.
- Deactivate non-essential plugins (aim for <15).
- Disable Plugins via FTP:
- If admin is inaccessible, rename
wp-content/plugins/toplugins-disabled. - Visit your site. If the error is gone, a plugin is the culprit.
- If admin is inaccessible, rename
- Identify the Culprit:
- Restore the
pluginsfolder name. - Move one plugin to a temporary folder (e.g.,
plugins-temp) and test. - Repeat until the error returns, indicating the faulty plugin.
- Common culprits: WooCommerce, page builders like Elementor.
- Restore the
- Replace or Optimize:
- Update the plugin or replace with a lightweight alternative (e.g., WP Rocket for caching instead of heavy optimization plugins).
Why It Works: Removing or optimizing heavy plugins reduces memory usage, preventing errors.
Pro Tip: Use WP Optimize to clean up plugin-related database bloat.
Step 4: Switch to a Lightweight Theme
Complex themes can consume excessive memory, triggering errors.
- Switch to Default Theme:
- Via FTP, rename your theme folder (e.g.,
wp-content/themes/astratoastra-disabled). - WordPress.com: Activate Twenty Twenty-Four via Appearance > Themes.
- Via FTP, rename your theme folder (e.g.,
- Test Your Site:
- Visit your site. If the error is resolved, the theme was the issue.
- Fix or Replace:
- Update the theme via Appearance > Themes.
- Switch to a lightweight theme like Astra for better performance.
Why It Works: Lightweight themes reduce memory-intensive code, freeing up resources.
Affiliate Link: Get fast themes from ThemeForest.
Step 5: Contact Hosting Support
If the above steps fail, your hosting provider may have strict memory limits or server issues.
- Check Server Settings:
- Log in to your hosting dashboard (e.g., SiteGround, Bluehost).
- Confirm PHP 7.4+ and memory allocation (e.g., 256M via cPanel).
- Submit a Support Ticket:
- Share
wp-content/debug.log(if available) and steps tried. - Request a memory limit increase or server diagnostics.
- Share
- Consider Upgrading Hosting:
- Shared hosting often caps memory. SiteGround offers high-memory plans with Google Cloud infrastructure.
Why It Works: Hosting support can adjust server settings or resolve underlying issues like resource limits.
Affiliate Link: Upgrade to SiteGround for ample memory and fast support.
Preventing WordPress Memory Limit Errors in 2025
- Monitor Memory Usage: Use Query Monitor to track resource consumption.
- Optimize Database: Clean regularly with WP Optimize.
- Limit Plugins: Keep <15 plugins and avoid heavy ones like page builders.
- Backup Regularly: Automate with UpdraftPlus.
- Use Fast Hosting: SiteGround ensures high memory limits.
- Test Updates: Use SiteGround’s staging to test plugins/themes.
Frequently Asked Questions
Q: Why does the memory limit error only appear in the admin panel?
A: Admin tasks (e.g., plugin updates) often use more memory. Increase WP_MEMORY_LIMIT to 256M.
Q: Can free hosting cause memory limit errors?
A: Yes, free plans typically cap memory at 32M-64M. Upgrade to SiteGround.
Q: How do I know if a plugin is too heavy?
A: Use Query Monitor to check memory usage per plugin.
Wrapping Up
Fixing the WordPress maintenance mode stuck issue is straightforward with this 2025 guide. By deleting .maintenance, resolving updates, and using reliable hosting like SiteGround, you’ll keep your site accessible. Want more fixes? Download my Free WordPress Troubleshooting Checklist or explore my guides:
- How to Speed Up a Slow WordPress Site (2025 Guide)
- How to Fix WordPress 404 Errors
- How to Fix WordPress Plugin Conflicts
- How to Fix WordPress Login Redirect Loop
- How to Troubleshoot WordPress Database Connection Error
- How to Fix WordPress Error 500 (Internal Server Error)
- How to Resolve WordPress Memory Limit Exhausted Error
- How to Fix WordPress Syntax Error in Code
- How to Troubleshoot WordPress Email Sending Issues
- Free WordPress Troubleshooting Checklist
Share your maintenance mode fixes on X or ask below! Visit my Resources page for top tools.
Download the Free WordPress Troubleshooting Checklist
If this guide helped, share it with a friend or follow TechBit for more WordPress troubleshooting tips!
Pingback: Free WordPress Troubleshooting Checklist (Essential Guide for 2025) - Techbit