"Fatal error: Allowed memory size of 67108864 bytes exhausted..."
This error indicates your WordPress site attempted to allocate more memory than PHP allows. The process ran out of resources and crashed.
The good news: this is usually fixable. The question is whether you need more memory or whether something on your site is using too much.
What This Error Means
Every time WordPress loads a page, PHP executes code that requires memory. Loading plugins, processing database queries, and generating pages all use server memory.
PHP has a configured memory limit, typically 64MB, 128MB, or 256MB, depending on your host. If your site exceeds that limit, you get this error.
Step 1: Increase the Memory Limit
First, check whether you can allocate more memory. There are several ways to do this:
Option A: wp-config.php
Add this line to your wp-config.php file, before the line that says "That's all, stop editing!":
define('WP_MEMORY_LIMIT', '256M');
This tells WordPress to request 256MB of memory from the server.
Option B: php.ini
If you have access to your php.ini file:
memory_limit = 256M
Option C: .htaccess
For Apache servers, you can try adding to .htaccess:
php_value memory_limit 256M
Option D: Contact Your Host
Many hosting providers set memory limits at the server level. You may need to contact them to increase it or upgrade to a higher-resource plan.
Note: If you're on a budget host, you may be hitting a hard limit that can't be increased without upgrading your plan. This is a common reason people outgrow cheap hosting.
Step 2: Ask Why It's Happening
Here's the thing: increasing memory limits is often just treating the symptom, not the cause.
If your site suddenly needs 512MB of memory when it used to work fine with 128MB, something changed. And simply throwing more memory at it might work for now, but it doesn't address the underlying problem.
Common Causes of Excessive Memory Usage
Poorly optimized plugins: Some plugins are inefficiently written, loading large amounts of data or running expensive queries on every page load. We see this constantly with plugins built by developers who don't consider performance.
Large database queries: If your site pulls thousands of records without pagination, all of them have to fit in memory at once.
Import/export operations: Tools that process large CSV files, import products, or export reports often need significant memory, sometimes more than your normal limit.
Image processing: Photo upload plugins or image optimization tools can exhaust memory when processing large files.
Accumulated plugin bloat: Over time, sites accumulate plugins. Each one adds memory overhead, even if it seems small.
When More Memory Isn't the Answer
If you're at 256MB or 512MB and still hitting limits, you probably don't need more memory. You need to optimize your site.
Look at Caching
Caching can dramatically reduce memory usage by serving pre-generated content instead of rebuilding pages from scratch. Options include:
- CDN caching: Cloudflare or similar services cache at the edge
- Server-level caching: Built into quality managed hosting
- Page caching plugins: WP Rocket, W3 Total Cache, etc.
- Object caching: Redis or Memcached for database query results
Optimize Database Queries
Large, unoptimized queries are a common culprit. Solutions include:
- Pagination: Don't load 10,000 records at once
- Transient caching: Store query results temporarily instead of re-running expensive queries
- Query optimization: Sometimes queries just need to be rewritten more efficiently
Audit Your Plugins
Deactivate plugins you don't actually need. Each active plugin consumes some memory, even if it's not doing anything visible on the page.
A Common Scenario
We often hear from potential clients who say, "I keep getting this memory error, but as soon as I have someone look at it, it goes away."
What's happening is intermittent. The site works fine under normal load, but certain actions or traffic spikes push it over the limit.
This usually means one of two things:
- You need better hosting with more consistent resources
- Something on your site is inefficient and needs optimization
Either way, it's worth investigating rather than just hoping the problem stays intermittent.
When to Call for Help
Memory exhausted errors can be symptoms of deeper issues. If:
- Increasing the limit doesn't help
- The error keeps coming back
- You're not sure why your site is using so much memory
Then it's time for someone to look under the hood. Finding and fixing inefficient code or queries is developer work, not something you can Google your way through.
What We Do
On FatLab-hosted sites, memory limits are already set generously. 256MB is our standard, with clients running 512MB or more for heavy applications.
When a client hits memory limits on our hosting, we know the issue isn't inadequate resources; it's something in the code that needs optimization. That's when we dig into what's actually consuming the memory and fix the root cause.
Hitting memory limits? Contact our support team to diagnose and fix the real problem.
This article is part of our WordPress Troubleshooting guide, a complete resource for diagnosing and fixing common WordPress errors.