How to Fix WordPress Memory Exhausted Error?

Here you can easily fix WordPress memory exhausted error by increasing the PHP memory limit. You can increase PHP memory limit via Cpanel, .htaccess file, WHM, wp-config.php file, and php.ini file etc.

WordPress memory exhausted error looks like this.

Fatal error: Allowed memory size of 67108864 bytes exhausted
(tried to allocate 2348617 bytes)
in /home/username/public_html/wp-includes/plugin.php on line 728

Increasing PHP Memory Limit in WordPress

From Cpanel

If you are using Cpanel on your hosting account, you can easily increase the PHP memory limit.

  • First, open Cpanel from your hosting account.
  • Under software, click on MultiPHP INI Editor link.
  • Under configure PHP INI basic settings, select your website.
  • Now, you can see the memory_limit option.
  • Then, change the value like 128M or 256M based on your server RAM.
  • Now, click on the apply button.
  • After that reboot your server.
  • Finally, memory limit successfully increased.

Via php.ini File

You can easily increase the PHP memory limit from the PHP INI file. Open php.ini file, then locate Resource Limits. Under resource limits, you can see the memory_limit option. Increase the value and save it.

Memory limit in php.ini file look like this.

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time=30

; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; Note: This directive is hardcoded to -1 for the CLI SAPI
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
; http://php.net/max-input-time
max_input_time=60

; Maximum input variable nesting level
; http://php.net/max-input-nesting-level
;max_input_nesting_level = 64

; How many GET/POST/COOKIE input variables may be accepted
;max_input_vars = 1000

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit=128M

How to find php.ini file?

  1. Create php file and add following code.

    You can easily find your php.ini file location. Just create a php file on your website root directory and place following code and run it.

    <?php phpinfo(); ?>

    You will get your php.ini file location on screen like this

    Loaded Configuration File: /etc/php5/cli/php.ini

Increase via wp-config.php

You can also set the memory limit in the WordPress configuration file. Edit this file only if above methods not work. Because if you make any mistake in this file, you may face some errors on your site.

  • First, open wp-config.php file with any code editor.
  • It’s located on root directory of your site.
  • Then add the following code in the configuration file.
define('WP_MEMORY_LIMIT', '256M');
  • Then save the file.
  • Finally, reboot your server if required.

Increase via .htaccess

You can also increase memory limit in .htaccess file.

  • First, open .htaccess file (Which is located on your website root directory).
  • If it’s not there, create a .htaccess file on your own.
  • Now, check your file, if it already has a memory limit code or not.
  • If not, place this code on the .htaccess file.
php_value memory_limit 256M
  • You can also change 256M to 512M or more based on your server RAM.
  • Now, save the file.
  • Finally, reboot your server if required.

Increase via WHM

If you are using WHM on your hosting, you can easily change the memory limit. This setting will apply to your php version, So all sites (Which have this php version) settings will be changed.

  • First, open WHM from your hosting account.
  • Under software, click on MultiPHP INI Editor link on the left side menu.
  • Under Configure basic settings of a PHP version, select your php version.
  • Now, you can see the memory limit option.
  • Change the memory limit to 256M or 512M based on your requirement.
  • Now, click on the apply button.
  • After that reboot your server.
  • Memory limit successfully changed.

Warnings

Only change file or setting if you know clearly about that file. If you make any mistake in editing, it will cause many errors.

Backup all your site before making any edits on your WordPress core files like wp-config.php.

General FAQ

How do I increase WordPress memory limit?

You can increase WordPress memory limit via php.ini file, via Cpanel, via WHM and via wp-config.php file, etc.

How do I increase WordPress Htaccess memory limit?

First open .htaccess file. Then place the memory limit code like this.

Leave a Reply

Scroll to top