Lost your GitLab 2FA device? How to get back into your account
Short answer
If you lost the device with your GitLab authenticator app, sign in with a recovery code: on the two-factor screen, select Recover your account. No codes left? If an SSH key on your account is on this computer, ssh git@gitlab.com 2fa_recovery_codes makes new ones. A registered passkey or WebAuthn device, or your authenticator app's own backup, also gets you in. On GitLab.com, Support resets 2FA only for accounts with a Premium or Ultimate subscription; a Free account that can't recover is locked out for good. Enterprise users can ask their top-level group Owner, and on GitLab Self-Managed an administrator can turn 2FA off for you in the Admin area.
Your phone is gone, or reset, and GitLab’s sign-in asks for a code from the authenticator app that was on it. Here’s how to get back in with GitLab 19.5, on GitLab.com or your own instance, in the order to try.
1. Use a recovery code
When you set up 2FA with an authenticator app, GitLab gave you recovery codes, in a download named gitlab-recovery-codes.txt if you saved them that way. To use one:
- On the sign-in page, enter your username or email and password.
- On the two-factor screen, select Recover your account.
- Enter a recovery code, and select Verify code.
Each code works once; the others stay valid.
2. Make new codes over SSH
No codes? If you added an SSH key to your GitLab account and this computer has its private key, GitLab can make new codes over SSH:
ssh git@gitlab.com 2fa_recovery_codes
On your own instance, use its hostname instead of gitlab.com. Answer yes, save the codes it prints, and sign in with one of them as above. The old codes stop working. If SSH answers Permission denied (publickey), often your key isn’t in the default place: load it with ssh-add first.
3. Use another factor
- A passkey or WebAuthn device you registered, such as a security key or another phone, signs you in instead of the app.
- An emailed code: if email one-time passcodes are on for your account, select Email code on the two-factor screen.
- Your authenticator app’s backup: many apps can restore their codes on a new phone, if backup was on before you lost the old one. GitLab Support can’t help with these apps.
4. Ask for a reset
- GitLab.com with a Premium or Ultimate subscription: open a ticket at GitLab Support and choose GitLab.com user accounts and login issues. Your support account is separate from your GitLab account.
- GitLab.com Free: Support doesn’t reset 2FA for Free accounts. If none of the steps above works, the account is locked for good, and you need a new one.
- Enterprise users on GitLab.com: your top-level group’s Owner can turn off your 2FA, under Manage › Members, with Disable two-factor authentication, or with the API if you aren’t a member of the group.
- GitLab Self-Managed: your administrator can turn off your 2FA in the Admin area, with Disable next to Two-factor Authentication on your user page, or with the users API or the Rails console.
After you’re back in, set up 2FA again right away.
Codes rejected
If GitLab rejects codes from a phone you still have, with Invalid two-factor code. at sign-in or Invalid pin code. when you register the app, its clock is probably off. Turn on automatic time: Set time automatically on Android, Set Automatically on iPhone. If it’s already on, turn it off and on again.
Email codes on GitLab.com
Since April 2026, GitLab.com has been making multi-factor authentication mandatory, account by account, for sign-ins and API requests that use a username and password. If you haven’t set up another factor, GitLab then emails you a one-time code at each password sign-in. It also emails a code after several failed sign-ins or from a new location. A code that didn’t arrive can be resent with Resend code, and if you can’t reach your primary email, you can send it to another verified email address on your account. Signing in with SSO skips the emailed code.
Don’t get locked out again
Once you’re in, go to your avatar, Edit profile, Access › Password and authentication, and select Regenerate recovery codes. Keep the new codes in a password manager. Register your authenticator app on the new phone, add a second factor, such as a passkey, and keep an SSH key on your account, so steps 2 and 3 work next time.
On your phone
On gitlab.com, MergeBell signs you in on GitLab’s own sign-in page, so the same two-factor steps apply there. On self-managed GitLab, it uses a personal access token, which keeps working with 2FA on. More on tokens in GitLab token scopes explained, and on Git sign-in errors in HTTP Basic: Access denied.
Frequently asked questions
How do I sign in to GitLab without my 2FA device?
Use one of the recovery codes GitLab gave you when you set up 2FA. Enter your username or email and password, select Recover your account on the two-factor screen, enter a recovery code, and select Verify code. Each code works once; the others stay valid.
How do I get new GitLab recovery codes without signing in?
If you added an SSH key to your GitLab account and have its private key, run ssh git@gitlab.com 2fa_recovery_codes, or your instance's hostname instead of gitlab.com, and answer yes. Save the new codes: the old ones stop working. If SSH answers Permission denied (publickey), the key is often not in the default place: load it with ssh-add first.
Can GitLab Support reset my two-factor authentication?
On GitLab.com, only for accounts with a GitLab.com subscription, Premium or Ultimate: open a ticket at support.gitlab.com and choose GitLab.com user accounts and login issues. GitLab Support doesn't reset 2FA for Free accounts, so a Free account that can't recover is locked out permanently and you need a new one.
Why does GitLab reject my 2FA codes with "Invalid two-factor code" or "Invalid pin code"?
Usually the clock on the device that makes your codes is off, so its codes don't match GitLab's. At sign-in the message is Invalid two-factor code, and when you register the app it's Invalid pin code. Turn on automatic date and time on the phone: Set time automatically on Android, Set Automatically on iPhone. If it's already on, turn it off and on again.
Why does GitLab.com email me a code when I sign in?
Since April 2026, GitLab.com has been making multi-factor authentication mandatory, account by account, for sign-ins and API requests that use a username and password, and an emailed one-time code is the second factor for accounts without another one. GitLab also emails a code after several failed sign-ins or from a new location. If you can't reach your primary email, you can send the code to another verified email address on your account.
Sources
- GitLab docs — Troubleshooting two-factor authentication
- GitLab docs — Two-factor authentication: recovery codes
- GitLab docs — Disable 2FA for a user or enterprise user
- GitLab blog — Support no longer processing MFA resets for Free users
- GitLab docs — Users API: disable two-factor authentication
Checked against these pages on 17 November 2026. GitLab changes quickly — if something here no longer matches, tell us and we will fix it.
Do this from your phone with MergeBell
Free for the whole review loop: the To-Do inbox, diffs and line comments, approve and merge, pipelines with retry, and push alerts for your To-Dos. Works with gitlab.com and self-managed GitLab 16.0+.
Get MergeBell for iPhoneGet MergeBell for Android
On the App Store for iOS 26 or later and on Google Play for Android 12 or later. An independent app, not affiliated with GitLab Inc.