Magento Developer Insights
January 12, 2024

“Front controller reached 100 router match iterations” error in Magento

By Liam Ashley
Front controller reached 100 router match iterations
“Front controller reached 100 router match iterations”- this is an issue that few Magent users will face. In this article, we’re going the discuss the problem, causes, solution, and debugging of this error. Let’s start.

“Front controller reached 100 router match iterations”- this is an issue that few Magento users will face. In this article, we’re going the discuss the problem, causes, solution, and debugging of this error. Let’s start.

What is the Problem?

If your site goes down multiple times a day and displays the message: “Front controller reached 100 router match iterations”. You can’t access admin and frontend once this happens. It’s just an error page that’s left.

What are the Causes?

It happens when Magento cannot find a proper route. This is because the router starts making infinitive references for dispatching requests.

Normally, it matches a request with the router. In exceptional cases, Magento fails to create routers and shows this error– Front controller reached 100 router match iterations 

How to Debug?

In app/code/core/Mage/Core/Controller/Varien/Front.php inside of the dispatch() function. You will find the following code snippet:

while (!$request->isDispatched() && $i++<100) {

    foreach ($this->_routers as $router) {

        if ($router->match($this->getRequest())) {

            break;

        }

    }

}

Replace the code above with:

Mage::log(‘—-Matching routers——————————‘);

Mage::log(‘Total ‘ . count($this->_routers) . ‘: ‘ . implode(‘, ‘, array_keys($this->_routers)));

while (!$request->isDispatched() && $i++<100) {

    Mage::log(‘- Iteration ‘ . $i);

    $requestData = array(

        ‘path_info’ => $request->getPathInfo(),

        ‘module’ => $request->getModuleName(),

        ‘action’ => $request->getActionName(),

        ‘controller’ => $request->getControllerName(),

        ‘controller_module’ => $request->getControllerModule(),

        ‘route’ => $request->getRouteName()

    );

    $st = ;

    foreach ($requestData as $key => $val) {

        $st .= “[{$key}={$val}]”;

    }

    Mage::log(‘Request: ‘ . $st);

    foreach ($this->_routers as $name => $router) {

        if ($router->match($this->getRequest())) {

            Mage::log(‘Matched by “‘ . $name . ‘” router, class ‘ . get_class($router));

            break;

        }

    }

}

The error log to be generated var/log/system.log.

Or you can also add the following debug code to app / code / core / Mage / Core / Controller / Varien / Front.php: Line 183:

if ($i>100) {

        file_put_contents(‘/tmp/debug.txt’, Mage::getConfig()->getNode()->asNiceXml());

               Mage::throwException(‘Front controller reached 100 router match iterations’);

 }

What is the Solution?

  • Change the admin URL in app/etc/local.xml to fix the problem if the error is found in the admin section. Replace urltoadmin value with the URL you want and your new admin URL should be: http://yoursite.com/urltoadmin

<admin>

    <routers>

        <adminhtml>

            <args>

                <frontName><![CDATA[urltoadmin]]></frontName>

            </args>

        </adminhtml>

    </routers>

</admin>

  • CMS module disabled: 404 not found requests are handled by the CMS module, it is a fallback router. As the module is disabled, no router can be found. Simply try enabling the CMS module and check if the issue is solved.
  • The cache is corrupted: Magento cache corrupted– this error causes when the list of routers never gets loaded. It’s because it loads from the cache and since the cache is corrupted, it does not contain this data. Simply flushing the Magento cache will help you resolve this issue. To remove cache corruption, you can also delete the /var/ cache folder.

Other possible solutions:

When upgrading or moving Magento, some cases went wrong:  Front controller reached 100 router match iterations.

Fix this error SQL and run the following command:

SET FOREIGN_KEY_CHECKS=0; UPDATE `core_store` SET store_id =0 WHERE code=‘admin’; UPDATE `core_store_group` SET group_id =0 WHERE name=‘Default’; UPDATE `core_website` SET website_id =0 WHERE code=‘admin’; UPDATE `customer_group` SET customer_group_id =0 WHERE customer_group_code=‘NOT LOGGED IN’; SET FOREIGN_KEY_CHECKS=1;

I hope this solution will help you solve the issue.

Information checked and edited by Liam Ashley

Last updated: August 9, 2024....
Liam Ashley is a highly skilled e-commerce specialist with a deep expertise in Magento 2. With over a decade of experience in the industry, Liam has become a prominent figure in the e-commerce landscape, known for his innovative solutions and strategic insights. Currently serving as the lead Magento 2 developer
Read more about Liam
Stay in the loop
Now you can update. Receive product updates, new and successful versions from Magstack customers directly in my mailbox.