Is your WordPress site showing the dreaded “Allowed memory size exhausted” error? This happens when your site needs more PHP memory than it’s allowed to use, causing:
- Failed operations (posts won’t save, images won’t upload).
- Display issues (white screens, broken layouts).
- Slow performance or crashes.
- Admin area problems (you can’t access the dashboard or make changes).
However, your memory limit problems can be solved in a matter of minutes. Read on to discover three proven methods to increase your WordPress PHP memory limit and optimize performance.
How to check your WordPress memory limit
Before making changes, it’s important to know your site’s current memory limit. WordPress makes this easy with built-in tools.
The quickest way to check is through Site Health (available in WordPress 5.2+):
- Find “PHP Memory Limit” to see your current setting.
- Go to your WordPress dashboard.
- Navigate to Tools > Site Health.
- Click the “Info” tab.
- Scroll to the “Server” section.


The number you see (typically 32M, 64M, 128M, 256M, or 512M) represents the maximum memory allocated to PHP scripts.
Recommended WordPress memory limits for different sites
WordPress memory requirements vary depending on your site’s complexity and functionality. Here’s what most sites need:
For standard WordPress sites (with 5-10 plugins and basic functionality):
- Blogs and simple business sites: 128MB-256MB.
- Portfolio sites with media galleries: 256MB.
For complex WordPress sites (with advanced features, custom code, or intensive processing):
- WooCommerce stores: 256MB-512MB.
- Membership sites: 256MB-512MB.
- Learning management systems: 256MB or higher.
Is 128MB sufficient for WordPress? For basic WordPress installations with minimal plugins, 128MB is sufficient. However, most modern WordPress sites benefit from at least 256MB for optimal performance.
How much memory does a WordPress site need? A typical WordPress site – one with a standard theme, 10-15 plugins, and moderate traffic (under 10,000 monthly visitors) – needs between 128MB and 256MB of PHP memory. This requirement increases with:
- Custom functionality.
- Number of active plugins.
- Media library size.
- Traffic volume.
Method 1: Increasing memory limit in wp-config.php
The most reliable way to increase your WordPress memory limit is by editing the wp-config.php file. This method works across most hosting environments and applies specifically to WordPress.
Here’s what to do:
- Navigate to your WordPress root directory (usually public_html or www).

- Access your WordPress files via an SFTP client like FileZilla or your hosting control panel’s file manager. For SFTP, you’ll need your SSH credentials, which you can get from your host. If you choose to use the hosting control panel, the exact steps will vary between hosts, but if yours uses cPanel, go to Tools > Files > File Manager.
- Locate the wp-config.php file – it’s in the root folder.
- Create a backup of the file before making changes. This is as easy as right-clicking it and downloading it to your device before editing.
- Open the file for editing using a text editor of your choice, such as Notepad++ or Sublime Text.
- Add this code before the line that says “That’s all, stop editing! Happy blogging” to set the PHP memory limit:
define('WP_MEMORY_LIMIT', '256M');
This line increases the PHP memory limit to 256MB. Feel free to adjust ‘256M’ to meet your needs or the limits imposed by your hosting provider. Common settings are ‘128M’, ‘256M’, or ‘512M’. - Save the wp-config.php file and upload it back to your server (overwriting the existing version).
To confirm your changes worked, go to Tools > Site Health > Info > Server and check the PHP Memory Limit value. It should now show 256M.
⚠️ If the memory limit hasn’t changed, your hosting provider might be restricting changes. In that case:
- Try the other methods in this guide.
- Contact your hosting support for assistance.
- Check if your server has memory restrictions in place.
Method 2: Using .htaccess to increase memory limit
If the wp-config.php method doesn’t work, modifying your .htaccess file is a good alternative. This approach works well on Apache servers or if your hosting allows .htaccess overrides.
Here’s what to do:
- Access your WordPress files using SFTP or your hosting control panel.
- Find the .htaccess file in your WordPress root directory (it’s sometimes hidden).
- Download a backup of the file before editing.
- Add this code at the end:
php_value memory_limit 256M
- Save and upload the file back to your server.
To verify the change worked, check your memory limit through Tools > Site Health > Info > Server. If you encounter a 500 server error after making this change, restore your backup immediately and try another method.
Method 3: Editing PHP.ini for higher memory limits
Editing your PHP.ini file increases memory limits server-wide, affecting all PHP applications on your server rather than just WordPress. This is ideal for multiple WordPress sites on the same hosting account.
The PHP.ini file location varies by host. It’s usually in the public_html folder, but some custom configurations might have it in non-standard locations. Certain hosts make it easier to access through a dedicated section in the control panel.
To modify the file:
- Locate your PHP.ini (or create one if it doesn’t exist).
- Add or edit this line:
memory_limit = 256M
- Save the file in your website’s root directory.
⚠️ Many hosting providers restrict PHP.ini modifications on shared hosting plans. If you can’t find or edit the file, check if your host offers custom PHP configuration in their control panel.
The “Allowed memory size exhausted” error explained
The “Allowed memory size exhausted” error appears when a PHP script on your WordPress site tries to use more memory than allocated. The full error typically looks like this:
Fatal error: Allowed memory size of XXXXX bytes exhausted (tried to allocate XXXXX bytes)
This error commonly occurs when:
- Installing or activating resource-intensive plugins.
- Importing large amounts of content.
- Uploading high-resolution images or videos.
- Outdated PHP versions.
- Low memory limit set by hosting provider.
- Running WP-Cron tasks for maintenance.
- Using page builders with complex layouts.
- Processing large WooCommerce product catalogs.
The impact on your site can range from minor to severe:
- Specific admin functions fail to complete.
- Media uploads become impossible.
- The WordPress editor crashes.
- Your entire site displays a white screen of death (WSOD).
The error message itself is WordPress trying to prevent server crashes by limiting PHP memory usage, which is why increasing the limit often resolves the issue.
Optimizing WordPress to reduce memory usage
Increasing your memory limit solves immediate problems, but optimizing your WordPress site reduces memory needs long-term. Here are effective approaches:
Plugin audit and cleanup:
- Remove unused plugins.
- Replace memory-heavy plugins with lighter alternatives.
- Keep only essential functionality.
Media optimization:
- Compress images before uploading using an image optimization plugin.
- Consider offloading media to cloud storage services if your site is media-heavy.
Database optimization:
- Clean post revisions, spam comments, and transients regularly.
- Optimize database tables monthly.
- Implement a database cleanup solution for automation.
Performance considerations:
- Add a caching layer to reduce PHP processing demand.
- Consider a Content Delivery Network (CDN) for serving static assets.
- Enable Gzip compression to reduce file sizes and server load
WordPress sets memory limits to prevent individual sites from consuming all server resources. On shared hosting, this ensures one site doesn’t affect others. Even on dedicated servers, limits prevent crashes from runaway scripts or poorly coded plugins, serving as a safety valve for your website’s stability.
When to upgrade your WordPress hosting to increase memory limit
If you’ve tried the methods above without success, you may have reached your hosting plan’s limitations. Before upgrading, contact your hosting support team about any restrictions. Ask if they can make a server-side exception for your account or allow temporary increases during maintenance windows.
If support can’t help, it may be time to upgrade your hosting. Watch for warning signs like frequent ‘memory exhausted’ errors despite your best efforts, a consistently slow admin dashboard, gradually increasing load times even with caching in place, regular 503 service unavailable errors, or noticing multiple sites competing for resources on one account.
When choosing a new hosting plan, remember that memory is just one piece of the puzzle. Take time to evaluate Central Processing Unit (CPU) allocation, PHP worker limits, database performance, server response time, and bandwidth caps to ensure your new hosting plan addresses all potential bottlenecks.
For WordPress-specific hosting solutions, consider providers like Kinsta or WP Engine that offer generous memory allocations (starting at 256MB), automated scaling during traffic spikes, and built-in performance tools designed specifically for WordPress sites. These specialized hosts often provide better resource isolation and WordPress-optimized environments that can resolve persistent memory issues.
Choose a plan that offers scalability for future growth and responsive technical support to help with any memory-related challenges.
FAQs
Will increasing memory affect site speed?
Yes, in a positive way. Increasing your WordPress memory limit allows scripts to execute completely without interruption, which typically improves performance. With more memory available, your site can handle complex operations more efficiently, resulting in faster page generation times and a smoother user experience.
What are the risks of setting memory limits too high?
Setting memory limits unnecessarily high can potentially allow poorly coded plugins to consume excessive resources. On shared hosting, this might trigger host-imposed restrictions. However, the main risk is creating a false sense of security – high limits might mask underlying inefficiencies that should be addressed through WordPress optimization instead.
Does WordPress memory limit affect mobile and desktop differently?
No, the PHP memory limit is a server-side setting that works the same regardless of the device accessing your site. Mobile and desktop visitors experience the same server environment. The memory limit affects how WordPress processes requests on your server before delivering content to any device.
Professional WordPress PHP memory optimization with Codeable
Sometimes memory issues require expert intervention, especially when they involve complex hosting configurations or custom code interactions. This is where Codeable‘s WordPress specialists excel.
Our vetted WordPress developers can:
- Diagnose the exact causes of memory exhaustion.
- Implement custom solutions beyond standard approaches.
- Optimize your site’s code for maximum efficiency.
- Configure server environments for optimal performance.
- Provide hosting migration assistance if needed.
Rather than spending hours troubleshooting complex memory issues yourself, Codeable connects you with pre-screened WordPress experts who can resolve your problems quickly and efficiently, getting your site back to peak performance.
Leverage the power of Codeable’s experts to elevate your WordPress site beyond mere functionality to excellence!