If you’ve just seen an error that goes along the lines of: “Fatal error: Allowed memory size of X bytes exhausted”
then you need to increase WordPress memory limit.
What this error means is simply that WordPress tried to use more memory than what your web server allows. Usually, WordPress only uses around 40MB of memory. This is okay for small sites, but can be not enough if you like to use some more elaborate plugins or themes.
Fortunately, there are ways to resolve this error. You can increase the memory limits in a couple of ways.
In this guide, I’ll show you four of the top solutions, and also explain what usually causes the error.
Key Takeaways
- Edit your
wp-config.php
file to increase memory by adding or adjusting theWP_MEMORY_LIMIT
line. Set to256M
. This works in most cases. - Use your hosting panel or
.htaccess
/php.ini
files to raise memory if wp-config changes don’t take effect due to server limits. - After increasing memory, monitor usage and remove bloated plugins or media to avoid hitting new limits or masking bigger issues.
Method 1. Edit the wp-config.php file
As you may know, the wp-config.php file is the main configuration file for WordPress. You can find it in your site’s root folder.
It’s mostly a text file, albeit it has various PHP definitions. inside. The way you increase WordPress memory limit through wp-config is by editing one of those definitions.
Here’s the step-by-step:
Step 1. Download/open your wp-config for editing.
Either use an FTP client to download wp-config to your desktop and then edit it from there, or use the File Manager tool in your hosting control panel to find wp-config in your site’s root directory and edit it directly on the server.
If you’re not sure how to FTP into your server, here’s a guide.
Step 2. Change the memory limit definition.
Look for a line that contains the text: WP_MEMORY_LIMIT
If you find such a line, edit the value next to it. You can make it 256M
to be safe. Like so:
define( 'WP_MEMORY_LIMIT', '256M' );
If no such line is already in the file, you can add it right above where it says /* That's all, stop editing! Happy blogging. */
Use the same format, so: define( 'WP_MEMORY_LIMIT', '256M' );

This tells WordPress that it can use up to 256MB of memory. Those 256MB is a common choice that handles most sites.
Step 3. Save the file (and upload)
Now refresh your WordPress site or redo the action that caused the error. The “memory exhausted” error should disappear if this method is effective.
👍 Pros: This is a straightforward solution. It will work in most scenarios and doesn’t really require any server-level access. It directly targets WordPress’ memory allocation and is the most reliable way across most environments
👎 Cons: WordPress cannot override the server’s hard limit if the host has one. In other words, if your hosting provider has capped PHP memory at (say) 64MB at the server level, setting WP_MEMORY_LIMIT
to 256M will not magically grant 256MB. This method only works up to the maximum allowed by the server.
Method 2. Edit the .htaccess file
On Apache-based servers, the .htaccess
file can override certain PHP settings if PHP is running as an Apache module. This file sits in the WordPress root folder. You can edit it normally – through Notepad or similar – and set a directive to increase the memory.
Here’s how:
Step 1. Find .htaccess
.
The .htaccess
file in your site’s root (same folder as wp-config.php
). The only difficulty is that it’s usually a hidden file, so depending on the tool you’re using to access it, you might need to show hidden files to see it.
If you’re using FileZilla to FTP into the server, then you’re going to see the file normally. However, once you download it to your desktop, this is when you need hidden files enabled to see it.
Step 2. Add PHP memory directive.
Open .htaccess
with Notepad or similar and add the following line at the top or before the # END WordPress
line:
php_value memory_limit 256M

This sets the PHP memory_limit
to 256MB for your site, overriding the default.
Step 3. Save and upload.
Save the file, upload it back to the server (override the original) and refresh your site or re-run the action that caused the error. If the .htaccess
change is allowed by the host, your site should now be able to use 256MB of memory.
👍 Pros: When permitted, this method changes the actual PHP environment limit for your site. It’s effective for Apache servers running mod_php
. The new limit applies to all PHP scripts, not just WordPress.
👎 Cons: Many shared hosts running PHP in CGI/FastCGI mode or with certain configurations disallow using php_value
in .htaccess
, which can lead to a “500 Internal Server Error.” If that happens, remove the line you added to .htaccess
to restore your site. This method is also ineffective on non-Apache servers (or some managed WordPress hosts) where .htaccess
is ignored altogether.
Method 3. Increase memory via your hosting panel
Many hosting providers offer a web interface to change PHP settings without manually editing files.
In cPanel (a popular hosting control panel, with hosts like Bluehost for example), this is often done through tools like MultiPHP Manager, MultiPHP INI Editor, or PHP Config.
Other hosts might have their own implementations of a hosting panel – like Hostinger‘s hPanel – and provide similar tools in their dashboards.
This method is generally very user-friendly and accomplishes the same result as editing php.ini
directly (I talk about this in the next section).
Here are the steps:
Step 1. Log into cPanel.
Navigate to the control panel provided by your host and find the section for PHP settings. For example, if you host at Bluehost, you’ll get a tool called MultiPHP INI Editor in the full cPanel dashboard (which you can access from the Advanced tab of your main Bluehost panel).

Step 2. Select your site/domain.
In the MultiPHP INI Editor, choose your domain or the location of your WordPress site. This will load the editable PHP configuration for that site.
Step 3. Edit memory limit.
Scroll through the settings to find the memory_limit
row. Enter your desired value (e.g. 256M
):

Step 4. Save changes and test.
Click Apply or Save. The configuration tool will update the relevant ini settings behind the scenes. Now your PHP memory limit for that site is increased. To confirm, you can go to Tools → Site Health → Info → Server in your WordPress dashboard. See the limit there:

👍 Pros: Using a hosting panel is the easiest method. There’s now coding or manual file editing required. The interface ensures you edit the correct configuration file. It’s also less error-prone since you’re not hand-editing syntax.
👎 Cons: Not every host offers such a panel, or it may be limited on basic plans. If your host’s interface doesn’t show an option for memory limit, you might be on a platform where you have to use a php.ini
file or request support assistance.
Method 4. Edit the php.ini or .user.ini file
The main PHP configuration file, php.ini
, controls the default memory limit and other settings of PHP – the programming language running your site a layer below WordPress.
On shared hosts, you often don’t have access to the global php.ini
, but many providers allow overrides via a custom php.ini
or a .user.ini
file in your account, which functions similarly to php.ini
.
Here’s how to use this approach:
Step 1. Determine the correct file to use.
Check your hosting for whether to use a custom php.ini
or a .user.ini
. You can get that info from the host’s docs or based on what’s already in your site’s root folder once you FTP into it.
Many modern shared hosts use .user.ini
in the web root for custom PHP settings. If a .user.ini
file doesn’t exist in your root folder, you can create a blank text file and name it .user.ini
(the leading dot is important).
Step 2. Add the memory limit setting.
Once you’ve identified the file you should be editing (php.ini
or .user.ini
) as per the previous step, now is the time to add (or update) a line looking like: memory_limit = X
Change the limit to something like:
memory_limit = 256M
This sets the PHP memory limit to 256MB for all PHP scripts running in that directory, which includes your WordPress installation.
Step 3. Save and verify.
Save/upload the file to your server. The new limit should take effect. To confirm, you can go to Tools → Site Health → Info → Server in your WordPress dashboard. See the limit there:

If the new limit didn’t take effect, you’ll need to restart your server.
👍 Pros: Adjusting php.ini
(or .user.ini
) changes the memory limit at the PHP configuration level. This is a rock-solid solution because it isn’t WordPress-specific. If your host permits custom ini files, this method effectively raises the ceiling that WordPress and other scripts can use. It’s especially useful if the wp-config.php method didn’t work due to a server-imposed cap.
👎 Cons: Not all shared hosts allow users to override PHP settings. It can also be tricky to locate the correct php.ini
if multiple PHP versions exist on the server. Always ensure you’re editing the correct file for your active PHP version. If uncertain, contacting your host support can save time.
What’s really causing WordPress memory limit errors?
Okay, so your WordPress decides it’s just run out of memory, but what does this really mean?
Understanding why these memory errors occur can help you prevent them in the future. After all, you cannot keep increasing the memory limit indefinitely.
On shared hosting, resources are limited and multiple websites share the same server, which makes efficient use of memory crucial.
Here are some common causes of the WordPress memory exhausted error:
- Heavy or poorly optimized plugins/themes. Plugins or themes that are very feature-rich, large, or coded inefficiently can consume large amounts of memory. If you add a new plugin or theme and start seeing memory errors, it’s a sign that it may be resource-hungry. For example, some visual page builders, analytics plugins running own custom tracking (very common), or security suites might load a lot of data into memory.
- The total number of plugins matters as well. Even well-built plugins use memory, so having an excessive number of active plugins can collectively eat up on that memory. Regularly auditing your plugins can free up memory for essential tasks.
- Uploading or processing large images, videos, or other media can spike memory usage, too. WordPress automatically creates multiple resized versions of each images on upload, which can be memory-intensive for big files. If your site deals with lots of high-resolution images, you may hit the memory limit during image manipulation. This is why large images can be memory hogs, and optimizing images is important (you might want to use Optimole for that).
- Certain background processes require significant memory. A prime example is backup plugins. When creating a full site backup (zipping up files and database), they can easily use hundreds of MB of PHP memory. Users often report memory exhaustion during backup jobs. Security scanners or malware cleanup plugins that go through all files, as well as import/export plugins or bulk data import tools, can also need more memory than usual.
- Lastly, over time, as your site’s content, traffic, and functionality grow, you may legitimately need more memory from your web host. A site that started small on a cheap shared plan can easily outgrow those limits as you add more posts, install some large plugins (like WooCommerce), receive more visitors, etc. If you consistently hit the memory ceiling, it might indicate your site has outgrown the current hosting resources and it’s time to consider upgrading your plan. This may involve moving to a higher tier, or switching to a different type of plan or host. When searching for a new host, I recommend paying careful attention to the amount of memory allocated as part of each plan. Wherever possible, try to find a provider that offers a default memory limit of 256 MB or higher.
Conclusion
Most of the time, you can upload files to your site and install additional software without any issues. However, at some point you may encounter the WordPress memory limit error.
Luckily, increasing the PHP memory limit using the methods in this post is pretty easy and it will fix the immediate error. In fact, setting the limit to 128MB or 256MB is often sufficient for most sites. However, be mindful that raising the memory limit is not a license to ignore inefficiencies.
After bumping up the memory, keep an eye on usage. Use the Site Health info to see how much memory is typically used. If you’re nearing the new limit, identify which plugin or process is using so much. Regularly clean up unused plugins and media.
Also, remember that on shared hosting, you are ultimately constrained by what the host allows. If you’ve tried editing wp-config.php
or php.ini
but the memory limit won’t adjust, it’s likely your host has enforced a cap. If that’s the case, you might have to consider an upgrade. 🤷♂️
👉 For other tips on WordPress issues like this one, check out our guide to WordPress troubleshooting. We also have a guide on how to fix the 20+ most common WordPress errors.
Do you have any questions about how to solve this common WordPress error? Let us know in the comments section below!
Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!