Are you seeing an allowed memory size exhausted error message in WordPress?
This is one of the most common WordPress errors, and you can easily fix it by increasing the PHP memory limit in WordPress.
In this article, we will show you how to fix the WordPress memory exhausted error by increasing the PHP memory limit.

What Is the WordPress Memory Exhausted Error?
WordPress is written in PHP, which is a server-side programming language. Additionally, every website needs a WordPress hosting server for it to function properly.
Web servers are just like any other computer. They need a certain amount of memory to efficiently run multiple applications at the same time. Server administrators allocate specific memory sizes to different applications, including PHP.
When your WordPress code requires more memory than the default allocated memory, you will see this error message:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx

Your WordPress site may be exhausting its server memory if it has:
- A lot of images, videos, and other types of media
- Plenty of unused WordPress plugins
- Outgrown its hosting plan resources
By default, WordPress automatically tries to increase the PHP memory limit if it is less than 64MB. However, 64MB is often not high enough.
Having said that, let’s see how to easily increase the PHP memory limit in WordPress to avoid the memory exhausted error.
How to Increase the PHP Memory Limit in WordPress
There are several ways to increase the PHP memory limit. One is to edit the wp-config.php file, another is to tweak the .htaccess file, and the last method is to check the php.ini file.
Let’s go through each one:
Editing the wp-config.php File
First, you need to edit the wp-config.php file on your WordPress site. It is one of the core WordPress files located in your WordPress site’s root directory, usually named public_html.
You will need to use an FTP client like FileZilla or file manager in your web hosting control panel.
Next, you need to paste the following line in the wp-config.php file just before the one that says, That's all, stop editing! Happy blogging.
define( 'WP_MEMORY_LIMIT', '256M' );
This code tells WordPress to increase the PHP memory limit to 256MB.
For more details, see our step-by-step guide on how to find and edit the wp-config.php file.
Once you are done, you need to save your changes and upload your wp-config.php file back to your server.
You can now visit your WordPress site, and the memory exhausted error should have disappeared.
Editing the .htaccess File
The next method is to edit the .htaccess file. This file is also located in the WordPress website’s root folder.
Here, you need to paste the following code before the line that says #END WORDPRESS
.
php_value memory_limit 256M
Similar to the previous code, it will tell WordPress to increase the PHP memory limit to 256MB.p
After that, simply save your changes and upload the file back to your web server. You can now open your WordPress website again to see if the memory limit error has gone.
If you can’t find the .htaccess file, check out our guide on why the .htaccess file may be missing and how to find it.
Checking Your php.ini File
If the above methods don’t work, you may want to look at your php.ini file.
php.ini is a file that controls your PHP settings, including the PHP version and PHP scripts. It’s not a WordPress core file, as your hosting provider usually manages it.
You can check its code to see your PHP memory usage limit. For more details, you can see our guide on how to find and edit the php.ini file.
However, because this is an advanced method, we recommend contacting your web hosting provider’s support team instead to see if they can increase the WordPress memory limit manually. Otherwise, this can result in further errors.
We hope this article helped you solve the WordPress memory exhausted error by increasing the PHP memory limit. You may also want to see our step-by-step beginner’s guide to troubleshooting WordPress errors, along with our expert picks for the best WordPress plugins to grow your site.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
karma tsheten says
AFter updating my .htaccess it gives me this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
WPBeginner Support says
To be safe, for the internal server error we would recommend going through the steps in our article below:
https://www.wpbeginner.com/wp-tutorials/how-to-fix-the-internal-server-error-in-wordpress/
If removing the code from the htaccess solves the issue, we would recommend reaching out to your host to see if they have a setting that could be the source of the conflict.
Admin
Jiří Vaněk says
Regarding the .htaccess file, be cautious. Many shared web hosting providers may have directives for increasing the memory limit disabled. Such a directive in the .htaccess file can cause a 500 error on the website, requiring its removal or commenting out. Be careful with this. Sometimes, simply increasing the memory limit may not solve the problem but rather delay it, like a painkiller. The pain might subside, but it doesn’t mean the cause has been resolved. Therefore, while increasing the memory limit might seem like a solution, it’s also important to check what is consuming the memory. Sometimes, people increase the memory limit from 512 MB to 1024 MB without considering whether it’s necessary, and whether the memory limit isn’t masking an underlying issue on the website.
WPBeginner Support says
Thank you for sharing your feedback on the htaccess change. Unless the host has very strict rules in place adding to the htaccess shouldn’t cause an error it is more likely to not work and would require you reach out to the host to request an override.
Admin
ROOK says
SAVED THE DAY!! TY
WPBeginner Support says
Glad our guide could help!
Admin
Qamar Shafique says
Thanks for this help.
WPBeginner Support says
You’re welcome!
Admin
Aisha says
It doesn’t solve my problem still shows an error after placing the code “define( ‘WP_MEMORY_LIMIT’, ‘256M’ );” and I also change the size of Memory_limit of Php.ini file
WPBeginner Support says
As we state in the article, if our code does not work, there is a good chance your hosting provider is overriding the memory limit and you would need to reach out to your host to fix the error.
Admin
Sohaib Siddiq says
It doesn’t solve my problem still shows an error after placing the code “define( ‘WP_MEMORY_LIMIT’, ‘256M’ );” & this is my front-end page showing
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 8192 bytes) in /home/X/wp-includes/class-wp-dependencies.php on line 260
WPBeginner Support says
If the code does not work for you, we recommend reaching out to your hosting provider as they may have a limit set on their end that could be the root of the issue.
Admin
Zachary Murri says
Thank you so much <3
WPBeginner Support says
You’re welcome
Admin
Bogosi says
Thank you for this!
WPBeginner Support says
You’re welcome!
Admin