TOTP authenticator codes are generated using the current time. If your phone's clock drifts by more than 30 seconds, every code you generate will be rejected โ even if it looks right.
In This Guide
Why TOTP Codes Go Out of Sync
Your authenticator app and the server both independently calculate the current 30-second time window. If your clock is off โ even by 31 seconds โ you'll be calculating a different window than the server, and your code will be wrong.
Common causes: airplane mode for extended periods, travelling across time zones, a faulty system clock, or a recently replaced phone battery.
Fix Time Sync on Android
- Open Settings
- Go to General management โ Date and time
- Toggle Automatic date and time off, then back on
- Your phone will sync with network time servers
Fix Time Sync on iPhone
- Open Settings โ General โ Date & Time
- Enable Set Automatically
- If already enabled: disable it, wait 10 seconds, then re-enable it to force a re-sync
Sync Time in Google Authenticator
Google Authenticator has a built-in time correction feature for Android:
- Open Google Authenticator
- Tap the three-dot menu (โฎ) โ Settings โ Time correction for codes
- Tap Sync now
On iPhone, Google Authenticator uses the system clock โ fix the iOS clock as described above.
Sync Time in Authy
Authy automatically synchronises time with its servers. If you're seeing wrong codes in Authy, the issue is almost certainly your device's system clock โ fix it using the Android or iPhone steps above.
After Re-Syncing
Your codes should start working immediately after fixing the clock. If codes are still rejected, the service may require you to wait 5โ10 minutes for the fix to propagate.
Why TOTP Codes Are Time-Dependent
TOTP (Time-based One-Time Password) codes work by combining your secret key with the current time. Both your authenticator app and the server independently calculate the expected code for the current 30-second window. If your phone's clock shows a different time than the server's clock โ even by a minute or two โ the code your app generates will not match what the server expects, resulting in an "Invalid code" or "Incorrect code" error.
How to Fix Time Sync on iPhone
Go to Settings โ General โ Date & Time and make sure Set Automatically is toggled on. This keeps your iPhone synchronised with Apple's time servers. If it is already on and you are still having issues, toggle it off, wait a few seconds, then toggle it back on to force a re-sync.
How to Fix Time Sync on Android
Go to Settings โ General Management โ Date and Time (location varies by manufacturer). Make sure Automatic date and time is turned on. Some Android versions also show a Sync now button. For Samsung devices, it may be under Settings โ General Management โ Date and Time โ Automatic date and time.
How to Fix Time Sync in Google Authenticator
Google Authenticator has a built-in time correction feature. On Android: tap the three-dot menu โ Time correction for codes โ Sync now. This corrects for any clock drift in the app itself, independent of your device's system clock. Note: this feature is available on Android; on iOS, rely on the system time setting.
The 30-Second Grace Window
Most servers accept not just the current 30-second window's code, but also the one from the immediately preceding window (the previous 30 seconds). This gives a 60-second total grace period to account for network latency and minor time differences. If your clock is off by more than about 30 seconds, even this grace period may not help โ use the time sync steps above.
Other Causes of TOTP Failures
Time drift is the most common cause, but not the only one. Other possibilities: you are entering the wrong code (check you are looking at the right account in your authenticator app); the code has just expired as you were typing (wait for the next code and enter it quickly); you have multiple entries for the same service and are using the wrong one (common after re-scanning a QR code without deleting the old entry); or the service has a stricter synchronisation requirement than standard. If syncing your clock does not fix the issue, try deleting the account from your app and re-scanning the QR code from the service's 2FA settings.