New: ShopBar Theme — faster, lighter, refreshed

See what's new
General

How to Increase PHP Memory Limit of Your WordPress Site 

Naitik Semwal

Spiracle Themes

6 min read

Are you receiving a WordPress memory exhausted error? Does the error tell you that your WordPress memory size has exhausted? It is one of the most common WordPress errors users often face. And the best thing is that you can easily fix this error by simply increasing the PHP memory limit in WordPress. As many of you may not know how to do that, we have come up with this article. Here we will discuss how to increase PHP memory limit of your WordPress site.

WordPress Memory Exhausted Error

Before we help you learn how to increase PHP memory limit of your WordPress site, let’s first discuss what WordPress memory exhausted error is. As you must know, WordPress is written in PHP, a server-side scripting language. For any WordPress site to function properly, it needs a WordPress hosting server. A web server works just like a computer does. It needs memory to run multiple applications at the same time. Specific memory size is allocated by the server admin to each of the applications including PHP.

Now let’s find out when this WordPress error appears. When your WordPress site requires more PHP memory than the allocated memory, you will get an error message saying – “Fatal error: Allowed memory size of x bytes exhausted”.

How to Increase PHP Memory Limit of Your WordPress Site  1

Although WordPress can automatically increase PHP memory limit if it is less than 64 MB, sometimes it is not enough. And that is why you encounter the memory exhausted error where you see a white screen with the error message. You may receive this WordPress error across your entire website or while performing certain actions like submitting a form. So you have to increase PHP memory limit manually to avoid the memory exhausted error.

How to Increase PHP Memory Limit?

Now, after discussing the memory exhausted error in detail, let’s find out how you can increase PHP memory limit. Well, it is very simple. Follow the steps given below – 

  • First, you need to edit the wp-config.php file of your WordPress website. And to edit this file, you need to locate it. The wp-config.php file is located in the root folder of your WordPress site.
  • To edit the file, you need to use either an FTP client or the file manager in your web hosting control panel.
  • In your wp-config.php file, you need to paste the following code just before the line “That’s all, stop editing! Happy blogging”.
    define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
  • The above code will tell WordPress to increase PHP limit of your WordPress site to 256 MB.
  • After making the changes to your wp-config.php file, you need to save it and upload it back to your server.

Now, when you will visit your WordPress site, the memory exhausted error will not appear again. If you have recently started using WordPress, then you might not be familiar with how to edit the wp-config.php file. Refer to this article for complete information – Editing wp-config.php. Here you will find the step-by-step method to edit the wp-config.php file.

Important Note

Some users say that even after increasing the PHP memory limit, they face the memory exhausted error. This happens just because your web hosting provider does not allow WordPress to increase PHP memory limit. So if the above method does not work for you, then you should contact your web hosting provider to look into the matter.

Conclusion

Through this article, we tried to help you to learn more about the memory exhausted error in WordPress. When this error appears, you have to increase PHP memory limit, either by yourself or by contacting your web hosting provider. We hope the information shared in this article will be helpful for you. Please give your valuable suggestions or feedback through the comments section below.

All the ways to raise the WordPress PHP memory limit

Editing wp-config.php is the quickest fix, but it is not the only one — and it cannot push past the limit your host allows. Work down this list until the memory-exhausted error disappears.

1. wp-config.php (most common)

Paste this just before the line “That’s all, stop editing! Happy blogging.”:

define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

2. php.ini

Add or edit memory_limit = 256M in your php.ini. This raises the true PHP ceiling, which wp-config.php alone cannot do.

3. .htaccess (Apache and LiteSpeed)

Add php_value memory_limit 256M inside the <IfModule mod_php> block of your .htaccess file.

4. Hosting control panel

In hPanel, cPanel or Plesk, open the PHP configuration for the site and set memory_limit directly. This is the easiest route on managed hosting.

5. Ask your host

On shared hosting the PHP limit is often capped. If the error returns after all of the above, ask support to raise the limit for your account — they can do it server-side.

Which memory value should you set?

Memory valueWhen it is the right choice
40MWordPress’s own front-end default — only enough for a very small site
64MThe automatic ceiling WordPress applies on its own; treat it as the minimum
128MLight sites running a handful of plugins
256MRecommended for page builders, WooCommerce and theme demos
512MLarge stores, big imports and heavy page builders
1024MOnly with dedicated resources and a genuine need

Frequently asked questions

What is the default WordPress memory limit?

40M for a single site and 64M for multisite, although most good hosts already set 128M–256M for you.

Where exactly do I put define( ‘WP_MEMORY_LIMIT’, ‘256M’ )?

Directly above the comment line “That’s all, stop editing! Happy blogging.” in wp-config.php, then save and re-upload the file.

Why did increasing the limit not work?

Because your host caps PHP’s memory_limit. wp-config.php can only raise WordPress’s share — to go higher, edit php.ini or the panel PHP settings, or ask support.

What is the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?

WP_MEMORY_LIMIT caps the front end of your site; WP_MAX_MEMORY_LIMIT caps wp-admin, where image resizing and imports happen. Set admin higher — for example 256M front and 512M admin.

How do I check my current PHP memory limit?

Go to Tools ? Site Health ? Info ? Server, or read the PHP settings page in your hosting panel.

Does a higher memory limit slow down my site?

No. It only raises the ceiling; PHP still allocates memory only when a script needs it.

More free WordPress themes from Spiracle Themes

We build and maintain these free WordPress themes in-house — all lightweight, schema-ready and free to download:

  • Colon WordPress Theme – lightweight multipurpose theme for blogs and business sites
  • Own Shop – free WooCommerce theme with one-click demo import
  • Blogson – free blog and magazine theme with clean typography
  • Crater – free business theme for startups and agencies
  • Krystal – free business theme with Elementor compatibility
  • PawWell – free pet-store theme with WooCommerce support

See the full collection on our WordPress themes page, or compare what the Pro membership adds.

If you are raising the PHP memory limit more than once, the site is outgrowing its setup rather than hitting a one-off limit. What a maintenance plan covers explains the routine checks that catch it earlier.

Written by

Naitik Semwal

Content Specialist at Spiracle Themes

Naitik Semwal is an active blogger, web content writer, and poet. Since 2012, he has been working in the software industry as a writer. Besides writing, he loves helping people with SEO and SMO strategies.

Leave a Reply

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