All Hosting Plan Are Also Available On Monthly, Quarterly And Semi-Annually.
< All Topics
Print

Fatal error: Allowed Memory Size Error in WordPress

A fatal error related to allowed memory size in WordPress means your website is running out of allocated PHP memory to complete a task. This is a very common issue, and you can fix it by increasing the memory limit in your WordPress configuration file.


What Causes the Error?

The error message “Fatal error: Allowed memory size of X bytes exhausted” occurs when a script, plugin, or theme on your WordPress site tries to use more memory than is currently assigned to PHP. This can happen during:

  • Plugin Activation or Updates: Some plugins require a lot of memory, especially during installation or updates.
  • Image Uploads or Manipulation: Processing large images, creating thumbnails, or resizing them can be very memory-intensive.
  • Running Complex Queries: Websites with a large amount of content or complex databases might hit this limit when running certain operations.

How to Fix the Error

You can fix this error by increasing the PHP memory limit in your WordPress configuration file.

Step 1: Access Your wp-config.php File

  1. Log in to your hosting account and navigate to cPanel’s File Manager.
  2. Open the public_html directory, which is the root of your WordPress installation.
  3. Find the file named wp-config.php.

Step 2: Edit the wp-config.php File

  1. Right-click on the wp-config.php file and select Edit.
  2. Add the following line of code just before the line that says /* That's all, stop editing! Happy blogging. */:
    PHP
    define( 'WP_MEMORY_LIMIT', '256M' );
    

    This line tells WordPress to increase the memory limit to 256 megabytes, which is sufficient for most websites. You can increase this number if needed, but 256M is a good starting point.

  3. Click Save Changes in the top-right corner of the editor.

Alternative Methods

If editing wp-config.php doesn’t solve the issue, you can try these other methods:

Editing the .htaccess file

You can add a line to your .htaccess file to increase the memory limit.

  1. In File Manager, find the .htaccess file in your public_html directory.
  2. Add the following line at the very top or bottom of the file:
    Apache
    php_value memory_limit 256M
    
  3. Save the changes.

Editing the php.ini file

This method requires you to have a php.ini file in your root directory.

  1. Create a new file named php.ini in your public_html directory if one doesn’t exist.
  2. Add the following line to the file:
    Ini, TOML
    memory_limit = 256M
    
  3. Save the changes.

If you are still experiencing the error after trying these steps, you may need to contact your hosting provider. Some shared hosting plans have a hard-coded memory limit that cannot be overridden by these methods.

Table of Contents

Windows Hosting is comming soon. All Hosting Plan Are Also Available On Monthly, Quarterly And Semi-Annually.

Call back request.