Memory Limit Errors in Shared Hosting (Fix Guide)

Quick Answer: A “memory limit exhausted” error means a PHP script on your Shared Hosting site tried to use more RAM than the server allocated to your account. This is usually caused by bloated plugins or poorly written code. Fix it by increasing your memory_limit in your php.ini file, disabling unused plugins, or optimizing your database. If you constantly hit this wall, your site has likely outgrown the restrictive nature of entry-level hosting.

You stare at your browser. Instead of your site, a blank white screen mocks you. Or worse, you see the text: Fatal error: Allowed memory size of X bytes exhausted. You were just trying to install a new plugin or update your theme. Now your business is effectively offline. This is the “Memory Limit Error,” the most common wall you will hit on a standard shared web hosting plan.

I have spent over a decade auditing site infrastructure, and I have never met a web developer who hasn’t encountered this. I do not have a personal history of using every hosting provider on the market, but I have analyzed enough server logs to know exactly what causes this. It is rarely a server-side hardware failure. It is almost always a code-level inefficiency. Your site is requesting more RAM than the server is configured to provide.

What Is the PHP Memory Limit?

When you pay for a hosting plan, you are not just paying for disk space. You are paying for a slice of the server’s physical memory. The server administrator defines a “memory limit” for every PHP process. This cap prevents a single site from hogging all the RAM and crashing the server for other users on that machine.

When you install a heavy plugin like a complex page builder or an automated backup tool it loads its entire library into that PHP memory slice. If your limit is 128MB and that plugin needs 130MB just to initialize, the server kills the process. Your site dies. It is not that you are out of RAM; you are just out of the specific “pocket” of RAM you are allowed to use at one time.

Why Your Website Exceeds the Memory Limit?

Stop looking for a single magic button. The memory limit is a symptom, not the disease.

  1. Plugin Bloat: You have too many plugins active. Even if they are not all doing something, they are often initialized on every page load.
  2. Theme Frameworks: Large, multipurpose themes often load hundreds of functions you do not need, consuming RAM before your actual content even loads.
  3. Unoptimized Queries: When you ask the database for thousands of rows at once, PHP has to store that data in RAM. If you don’t use pagination, you’ll quickly exceed your limit.
  4. Bot Attacks: If a bot is constantly scanning your login page or search results, it forces the server to create many concurrent PHP processes. Each one consumes memory, and the total usage stacks up.

PHP Memory Usage and Performance Comparison

TaskEstimated RAM NeededImpact on Memory Limit
Simple HTML Page< 1MBNegligible
Standard WordPress Load32MB – 64MBModerate
Multipurpose Theme Load128MB – 256MBHigh
Image Processing/Resizing128MB+Very High
Database-Heavy Export256MB+Severe

Recommended for: Simple sites can run on 128 MB. If you are running WooCommerce or a page builder, you need at least 256 MB to avoid daily crashes.

How to Fix PHP Memory Limit Errors

Before you call support, try these steps. They work 90% of the time.

Step 1: Edit the php.ini File

Access your site via FTP or your file manager. Locate the php.ini file in your root directory. If it doesn’t exist, create it. Add this line:

memory_limit = 256M

This tells the server to give your PHP processes more room to breathe.

Step 2: Update wp-config.php

WordPress has its own memory setting that can override the server default. Open wp-config.php and look for the line that says “That’s all, stop editing!” Above it, add this:

define(‘WP_MEMORY_LIMIT’, ‘256M’);

Step 3: Check .htaccess

Sometimes the server configuration blocks the php.ini changes. Add this to your .htaccess file:

php_value memory_limit 256M

If your server returns a 500 Internal Server Error after this, remove it immediately. Your host likely forbids this method.

Step 4: Audit Plugins

Turn off all your WordPress plugins. If the problem goes away, turn them back on one at a time. Check how much memory your site is using after each one. When your site crashes, you will know which plugin is causing the problem. Get rid of that plugin or find one to use instead.

Step 5: Clean the Database

Your database can get filled with versions of posts and comments you threw away, as well as leftover data from plugins you are not using. You can use a plugin, like WP-Optimize, to clean up all the stuff. This will make your database smaller. That means it will use less memory while running queries.

How Much PHP Memory Does Your Website Need?

Most modern WordPress installations perform perfectly on 128MB of memory. If you find that your site requires 512MB or more, something is wrong. You are not “doing more,” you are “being inefficient.”

Source data indicate that a simple WordPress setup typically uses no more than 64 MB for the frontend. If your site still needs 512MB to work properly, it is likely because you are using a “builder” that creates a lot of unoptimized code. You are actually working against the platform of using it efficiently. If you have already removed parts and still need more than 512MB, it is time to be honest with yourself: your current hosting environment is not strong enough to handle the load you are putting on it.

Choosing the Right Solution for Your Website

For Beginners and Personal Websites

You just want your site to load. You are likely installing plugins for every small feature. Stop. Every plugin is a line of code that requires memory. If you encounter an error, the usual fix is to delete the plugin rather than keep increasing your memory limit.

For Agencies and High-Traffic Websites

You manage multiple clients. If you keep hitting memory limits, you are setting yourself up for failure. Do not try to hack the memory limit to 1GB. It won’t work, and you will just anger the server admin. Move your clients to a containerized hosting environment where each site has dedicated resources.

Hosting Costs and Memory Upgrade Considerations

Increasing your memory limit is essentially free if your host allows it. But if you need to move to a higher hosting tier to get a higher cap, expect to pay $15–$30 more per month. If you are making money from your site, this is a minor investment. If you are not, you should be cutting costs by optimizing your site, not by buying more server power.

Security and Best Practices

Memory limits are a common vector for Denial of Service (DoS) attacks. If an attacker can force your server to run a script that consumes 512MB of RAM, they only need a few concurrent visitors to crash your site entirely.

  • Limit Login Attempts: A simple plugin that limits login attempts helps prevent brute-force attacks by preventing brute-force bots from spawning memory-intensive processes.
  • Disable XML-RPC: This feature is often used by bots to execute large, memory-hogging requests. Unless you use a mobile app to post to your site, turn it off.
  • Keep PHP Updated: Newer versions of PHP are significantly more memory-efficient. Moving from PHP 7.4 to 8.2 can sometimes cut your memory usage by 20% or more.
  • Use Object Caching: Redis or Memcached can store database results in RAM. This prevents your site from constantly querying the database, saving a massive amount of PHP memory.

Troubleshooting: The War Room

When the site goes down, do not guess. Run through this list.

  • Problem: Site crashes during a plugin update.
    • Cause: The update process is memory-intensive.
    • Fix: Temporarily increase the memory limit. If it still fails, update your plugins one by one rather than in bulk.
  • Problem: Memory error on the frontend, not the backend.
    • Cause: A page template is trying to load too much data.
    • Fix: Look for custom loops in your theme that are fetching every single post instead of using pagination.
  • Problem: The error occurs only at specific times.
    • Cause: A cron job is running.
    • Fix: Check your scheduled tasks. If you have a backup running, it is likely the cause. Schedule it for off-peak hours.
  • Problem: You increased the limit, but the error persists.
    • Cause: The server is overriding your change.
    • Fix: Check if your host imposes a “hard limit” that you cannot override via php.ini. Contact support to see what the maximum allowed value is.
  • Problem: PHP 8+ shows different errors than PHP 7.
    • Cause: PHP 8 is stricter with memory management.
    • Fix: You may need to optimize your code. PHP 8 will crash on bad code that PHP 7 might have just ignored.

Conclusion

Hitting a memory limit is a sign that your site has outgrown its current “diet.” It is rarely the host’s fault. It is usually the result of a site that has accumulated too much bloat over time. Most owners try to solve this by throwing more RAM at the problem, but that is a temporary patch.

To get your site back to a healthy state, take these three actions immediately:

  1. Audit your plugins: If you are not using it, remove it.
  2. Optimize your database: Clear out the junk data that your queries are forced to load.
  3. Check your code: Use tools like Query Monitor to identify the exact plugin pushing your RAM usage over the edge.

If you have done these things and you are still hitting the ceiling, you have reached a growth milestone. Treat it as a sign that your business is evolving. It is time to audit your hosting plan and consider if a dedicated environment is the right move to ensure your site stays fast, reliable, and available for your customers.

Frequently Asked Questions

Why does my site keep running out of memory even after I increased the limit?

Simply increasing the number is not a cure-all. If your site code has a memory leak a process that keeps grabbing RAM and never letting it go you will eventually hit the new limit, no matter how high you set it. You need to identify the specific plugin or theme file that is misbehaving and replace it with a more efficient version.

Is 256MB enough for a standard business website?

Yes, 256MB is the “gold standard” for most WordPress business sites. It provides enough overhead for standard themes, WooCommerce, and essential plugins like SEO and security tools. If you are constantly hitting this limit, you likely have a configuration issue, a problematic plugin, or an overly complex page builder generating massive amounts of unnecessary code.

Does increasing the memory limit slow down the server?

Increasing your memory limit on its own does not slow down the server. However, if every site on the shared server tries to allocate 512MB of RAM at the same time, the server will run out of physical memory and start swapping to disk, which will grind the entire machine to a halt. This is why many shared hosts cap your limit at 128 MB or 256 MB.

Can I use a plugin to fix the memory limit?

There are plugins that claim to increase the memory limit by editing wp-config.php for you, but they are unnecessary. You can easily do this yourself by editing the file directly. Using a plugin adds another layer of code to your site, which ironically consumes more memory. Just perform the change manually; it takes two minutes and requires no extra software.

Will moving to a VPS permanently fix memory limit errors?

Moving to a VPS gives you control over the server environment, meaning you can set the memory limit as high as your physical RAM allows. However, it does not fix bad code. If your site is inherently inefficient, a VPS will just give you a larger “bucket” to leak water into. You must optimize your site’s performance first before moving to a more expensive environment.

How do I know if my host is the problem or my site is?

The easiest way to tell is to create a simple info.php file with the command <?php phpinfo(); ?> and upload it to your server. Load that page in your browser. It will show you the exact memory limit currently active for your account. If the limit shown is much lower than what you expected, your host is enforcing a hard cap, and you should contact their support team for clarification.

Latest Posts:

Facebook
Twitter
LinkedIn
Email

Leave a Reply

Your email address will not be published. Required fields are marked *

Limited-Time Offer
Get 50% Off Your First Year of Hosting with Webhozta!
Signup for our newsletter to get updated information, promotion & Insight.