If you’ve ever seen the dreaded “Allowed memory size of X bytes exhausted” error in WordPress, you’re not alone. This happens when WordPress runs out of memory while executing a task—usually when installing plugins, uploading large images, or running memory-intensive operations.
The default WordPress memory limit is typically 32MB to 64MB, which isn’t enough for many modern sites. Here’s how to increase it.
What is the WordPress Memory Limit?
WordPress memory limit is the maximum amount of server memory (RAM) that PHP can use to run your WordPress site. When your site tries to use more memory than allowed, you’ll see errors like:
Fatal error: Allowed memory size of 67108864 bytes exhausted- White screen of death (WSOD)
- Plugin/theme installation failures
- Image upload errors
How to Check Your Current Memory Limit
Before increasing the limit, check what it’s currently set to. Add this to any PHP file or use a plugin:
<?php echo 'Memory Limit: ' . ini_get('memory_limit'); ?>
Or check via Tools → Site Health → Info → Server in your WordPress dashboard.
Method 1: Edit wp-config.php (Recommended)
This is the most reliable method and works on most hosting providers.
- Connect to your site via FTP or File Manager
- Open
wp-config.phpin your WordPress root directory - Add this line before the line that says
/* That's all, stop editing! */:
define('WP_MEMORY_LIMIT', '256M');
For admin tasks that need more memory:
define('WP_MAX_MEMORY_LIMIT', '512M');
- Save the file and refresh your site
What these values mean:
WP_MEMORY_LIMIT- Memory for front-end operationsWP_MAX_MEMORY_LIMIT- Memory for admin/backend operations
Method 2: Edit .htaccess File
If your server runs Apache, you can modify the .htaccess file:
- Open
.htaccessin your WordPress root directory - Add this line at the top:
php_value memory_limit 256M
- Save and test your site
Note: This only works on Apache servers. If you’re on Nginx, skip to the php.ini method.
Method 3: Edit php.ini
If you have access to your server’s PHP configuration:
- Locate or create a
php.inifile in your WordPress root - Add or modify this line:
memory_limit = 256M
- Restart your web server
Some hosts don’t allow custom php.ini files. Contact your hosting provider if this doesn’t work.
Method 4: Contact Your Hosting Provider
If none of the above methods work, your hosting provider may have restrictions in place. Shared hosting often caps memory limits.
What to ask:
- “Can you increase my PHP memory limit to 256M?”
- “What’s the maximum memory limit allowed on my plan?”
Most quality hosts will do this for free. If they refuse or charge extra, it might be time to consider upgrading your hosting plan.
Method 5: Use a Plugin (Quick Fix)
If you’re not comfortable editing files, plugins like WP Memory Usage or Health Check & Troubleshooting can help identify memory issues. However, they can’t actually increase limits—that requires server-level changes.
How Much Memory Do You Need?
Here’s a general guide:
| Site Type | Recommended Memory |
|---|---|
| Simple blog | 128M |
| Standard WordPress site | 256M |
| WooCommerce store | 256M - 512M |
| Large site with many plugins | 512M+ |
Warning: Don’t set the limit higher than your server actually has. If your hosting plan includes 512MB RAM, setting the limit to 1GB won’t help—and could cause issues.
Still Getting Memory Errors?
If increasing the limit doesn’t help, the problem might be elsewhere:
- Poorly coded plugins - Disable plugins one by one to find the culprit
- Theme issues - Switch to a default theme temporarily
- Too many plugins - Each plugin uses memory; remove unused ones
- Large images - Optimize images before uploading
- Outdated PHP - Upgrade to PHP 8.0+ for better memory management
Quick Troubleshooting
Memory limit shows correct value but still getting errors?
- Your host may be overriding settings
- Try a different method (wp-config vs .htaccess)
- Contact hosting support
Changes not taking effect?
- Clear any caching plugins
- Clear your browser cache
- Wait a few minutes for server changes to propagate
Conclusion
Increasing your WordPress memory limit is usually straightforward:
- First try: Add
define('WP_MEMORY_LIMIT', '256M');to wp-config.php - If that fails: Try .htaccess or php.ini
- Last resort: Contact your hosting provider
Most sites run fine with 256MB. If you consistently need more, consider optimizing your site or upgrading to better hosting.
Got questions? Drop a comment below and I’ll help you troubleshoot.