Can't enable 2FA

I had 2FA enabled until just a moment ago. After my computer restarted abruptly (thanks Windows :roll_eyes:), I was locked out on homeassistant.local:8123, because it wouldn’t accept my 2FA code. Thankfully, I was still logged in on nabu casa, so I was able to disable the 2FA.

Now I am unable to enable it again. When I try to set it up again, it is giving this error message:
Invalid code, please try again. If you get this error consistently, please make sure the clock of your Home Assistant system is accurate.

I am on HA OS 7.5, Core 2022.3.5.

I have already tried restarting HA Host. I am not sure what else to try.

Hi,

Unfortunately, I’m not sure how to fix this apart from saying check your timezone settings. I’m not sure where you’re based but if you’re in the UK the clocks went forward by 1 hour today and this might be causing the issue. I need to investigate similar things on my side too as had a node-red automation trigger an hour late which I think is also related to the clocks.

Took me a while, but I finally figured out that after my laptop rebooted (on its own), the clock on Windows was off. And none of my 2FA were working, if copied from the Bitwarden browser extension. After fixing my laptop’s clock, it started working again.

Windows… sigh

I’m having this issue and I’ve doubled triple check all clock settings, timezone etc, nothing is working.

Trying to add 2fa on my phone

Ok I solved this by manually installing ntp in debain,

apt install ntp

then configuring to use local NTP servers from

/etc/ntp.conf

and set it to use your local NTP server pools.

After this, I was able to setup 2FA. I guess HA grabs its time from the HOST.

1 Like

Thanks, this helped me to resolve my problem. My time on the VM was just 5 minutes behind. Installing NTP has corrected issue right after installation automatically.