Magento Reindex throw error: PHP Fatal error: Allowed memory size of 262144 bytes exhausted

Table of Content

Solution found on here.

I just ran across this issue and it threw me for a loop for several hours so I thought I would share the solution here. In my case I was attempting to reindex a Magento database via php cli on the command line, however this issue is not Magento specific. For those Magento folks out there here is the command line along with the full error message.

Command: php indexer.php –reindexall


PHP Fatal error:  Allowed memory size of 262144 bytes exhausted (tried to allocate 90 bytes) in /var/www/html/ on line 441

Pretty straight forward error message. I only have 262k of memory available for php to do it’s business which is not enough to run the script. I check my memory_limit with “php -i | grep memory_limit” and see that it’s set at 512M. Clearly the command line client is not using my php.ini memory_limit.

In most cases this error is fixed by simply adjusting the memory_limit however we have a mismatch between what php cli is using and what our php.ini is configured for. On a side note I found several forums indicating the possibility of two php.ini files, one for the web server and one for the command line client. I only have one php.ini but be sure to run “php -i  | grep php.ini” to make sure you’re editing the right one if you need to make changes to php.ini for the command line client.


This error is caused by the presence of a .htaccess file which defines “php_value memory_limit 512M”. Your amount may not be 512M but you get the point.


Comment out “php_value memory_limit 512M” in your .htaccess file.

Leave a Reply

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