Categories
Magento Knowledge Quick Tips

Magento 2 error “Maximum function nesting level reached”

Last Updated on 2021-06-17 by aeno

If you have Xdebug installed on your local development machine, you might experience the following error when running Magento:

Fatal error: Maximum function nesting level of ‘256’ reached, aborting!

(instead of 256, the reported nesting level might be different)

Magento 2 is a complex piece of software with many classes that get called on every request.
When the Xdebug PHP extension is installed, it introduces a mechanism that stops execution after a certain amount of nested function calls was reached. According to the documentation it is set to a value of 256 by default.

This is a known issue with all Magento 2 versions and Xdebug and can be resolved by either:

  • disabling Xdebug
  • or increasing the php.ini configuration value for xdebug.max_nesting_level

Increase the Xdebug setting max_nesting_level

Find out, what .ini files are in effect in your PHP environment. You can do this by running php --ini on your command line or by creating a PHP file with the content <?php phpinfo(); and viewing it in your browser.
In both cases, PHP will tell you all the .ini files currently in use and it will look similar to the following:

Locate your xdebug.ini and add the following line to the end of its contents:

xdebug.max_nesting_level = 512
Code language: plaintext (plaintext)

Restart your web server (or php-fpm if you use it) and check whether the error was resolved. If not, you can try to further increase the nesting level and try again.

Leave a Reply

Your email address will not be published.