Knowledge Base
  1. Home
  2. Knowledge Base
  3. WordPress Tutorials
  4. How to Fix WordPress Fatal Error Allowed Memory Size

How to Fix WordPress Fatal Error Allowed Memory Size

This article we will cover one of the most common WordPress errors: “Fatal error: Allowed memory size exhausted”. What causes it and the different ways to resolve it.

Analyzing the Error

By default, a new WordPress install will have an allocation of 64M, but this is not always enough.

In most cases, once you install a new theme or plugin that requires a higher server memory limit, of which is not allocated within your WordPress environment, then you are likely to encounter this error within your browser, once you try accessing your website.

A sample format of the error would be rendered as:

Fatal error: Allowed memory size of 33455443 bytes exhausted (tried to allocate 2211214 bytes) in C:\wamp64\www\wp-includes\functions.php on line 5231

Note that you will only be in a position to have a view of the error if you have enabled debugging within your WordPress environment. Otherwise, a “White Screen” would be rendered. Enabling debugging within your WordPress environment can be accomplished from the wp-config.php file.

You can access the wp-config.php file within the root of your WordPress install. As per the sample error above, of which is within a local install, the file will be within the directory path C:\wamp64\www\

If your website is already uploaded, you can access the file using an FTP client software such as Filezilla or WinSCP. Connecting to your website via FTP requires a specific set of credentials. You can consult your host on the required FTP login details if you are not in a position to trace these on your end.

As an alternative, you can also access the file via the control panel provided by your web hosting and navigate to the /public_html/ folder where you will find the file in place.

Once you are in a position to replicate the error, then you can proceed to determine a way on how to go about fixing the error.

Fixing the Error

There are a couple of ways on how to go about resolving this error. These include:

  • Editing the wp-config.php file
  • Editing the php.ini file
  • Editing the .htaccess file

In these three methods, the first step would be in analyzing the amount of additional memory required. This would be different across different installs.

Let’s cover each of these methods:

1. Editing the wp-config.php file

Here you will need to edit the wp-config.php file. Prior to this, I would recommend creating a backup of this file by downloading it your local computer or else saving it to your desktop if your website is within a local install. This would serve as a safety precaution in case you would wish to restore to an earlier state.

With this accomplished, you can then add the code below just prior to the line that says “That’s all, stop editing! Happy blogging”

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

The M means megabytes. A 256M memory allocation would be appropriate for most installs. You can, however, have the value raised higher to 512M, depending on the extra memory allocated needed.

Once this is done, save your changes and try accessing your website URL to see if the error is resolved. If so, you should have a view of your site content or else the accessed URL content.

In some instances, this method may not work. This happens in instances whereby you are on a shared hosting and the hosting provider does not allow such a change. In such a situation you may need to consult your hosting provider on this issue.

2. Editing the php.ini file

The php.ini file is a configuration file that is read once a PHP script is executed or else when PHP starts.

You can use this file to control resource limits such as the required memory in our case here.

On a live install, the file can be accessed within the root of your install, that is within the /public_html/ folder. Note that the file is not installed by WordPress but in most cases set up by your host. If you are using CPanel as your control panel, for example, make sure the checkbox for “Show Hidden Files” is checked and then click Go. You may check into this article on how to go about editing the file.

Before editing the file, kindly preserve a backup to it by downloading it to your computer.

Once this is done, open the file, add or edit the following line:

memory_limit 512M

After, press save and close.

As for local installs, the location of the file will depend on the Local server in use. In our sample here using WAMP, you will need to:

  • Start WAMP server and wait for the WAMP icon in the taskbar to turn green.
  • Left click on the icon.
  • Select PHP > php settings > memory limit.
  • Change the value to 256.

This will by default change the setting in php.ini.

3. Editing the .htaccess file

The .htaccess file is a file located within the root of your WordPress files.

Again we would advise you to carry out a backup of this file.

If the alteration to the php.ini file did not work, you can choose to edit this file.

You will need to add or edit the following code to the bottom of the file:

php_value memory_limit 256M

With this done, you can then save your changes and check if the error is resolved.


In any case, the methods above do not work out for you, or else you would not wish to carry out these changes yourself, I would recommend on consulting your hosting provider on this so that they can have the limit increased from their end.

Was this article helpful?
Related Articles