After Upgrading My Site to Magento version 2.4.3 I am facing this issue on my admin login at 2FA Login screen.

2FA Login screen

Please Help me About this why its showing the invalid form key.

3 Answers 3


Magento 2.4.3 has a known bug causing this problem. One user reported your exact problem. From that Github issue, this solution is reported to work until Magento patches this in a future release. I'm unable to paste it here as it doesn't appear to play nice with StackExchange formatting tools, but those links should get you to a solution.

  • Thank You @kookaburra Commented Oct 1, 2021 at 12:13

Run below command in terminal Magento root path :

bin/magento module:disable Magento_TwoFactorAuth
bin/magento cache:flush 
  • 1
    I Want TwoFactor on my site Commented Sep 30, 2021 at 12:46
  • This is not an issue,Just refresh your page and try it again Or try by increasing values in php.ini max_input_vars = 200000 max_input_time = 600 max_execution_time = 3600
    – Fatma
    Commented Sep 30, 2021 at 13:03

You have to change default Magento's File

Go to , Magento/Backend/App/Action/Plugin/Authentication.php

find protected function _redirectIfNeededAfterLogin() function

And Replace With Below Code :

 protected function _redirectIfNeededAfterLogin(\Magento\Framework\App\RequestInterface $request)
    $requestUri = null;

    // Checks, whether secret key is required for admin access or request uri is explicitly set
    if ($this->_url->useSecretKey()) {
        $requestParts = strpos(trim($request->getRequestUri(), '/'), $request->getFrontName()) === 0 ?
            explode('/', trim($request->getRequestUri(), '/'), 4) :
            explode('/', trim($request->getRequestUri(), '/'), 3);
        if (($key = array_search($request->getFrontName(), $requestParts)) !== false) {
        $requestParams = $request->getParams();
        unset($requestParams['key'], $requestParams['form_key']);
        $requestUri = $this->_url->getUrl(implode('/', $requestParts), $requestParams);
    } elseif ($request) {
        $requestUri = $request->getRequestUri();

    if (!$requestUri) {
        return false;

    $this->_actionFlag->set('', \Magento\Framework\App\ActionInterface::FLAG_NO_DISPATCH, true);
    return true;

Changes in Default Magento files is not a god practice, until you have to wait Magento official to fix this bug...Or Use this Solution Its Working in my case

Ref : Github

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.