1 ---
2 title: Recovering your 2FA-enabled account
3 ---
4
5 import shared from '~/shared.js'
6
7 When you have two-factor access enabled on your account, and you lose access to your 2FA device, you may be able to recover your account using the following methods.
8
9 ## Misplaced second factor device
10
11 If you have misplaced the device that provided second-factor authentication, you can use the recovery codes generated when you [enabled 2FA][setup-recovery-codes] to access your account.
12
13 ### Using recovery code on the web
14
15 1. Locate the recovery codes generated that you have saved.
16
17 2. <>{shared['user-login'].text}</>
18
19 <>{shared['user-login'].image}</>
20
21 3. <>{shared['use-recovery-code'].text}</>
22
23 <>{shared['use-recovery-code'].image}</>
24
25 _Note: If you have configured to use TOTP, you will see an TOTP prompt instead_
26
27 4. Enter an unused recovery code in the "Use a Recovery Code" prompt.
28
29 <Screenshot src="/getting-started/setting-up-your-npm-user-account/user-a-recovery-code.png" alt="Screenshot showing use a recovery code prompt with an input box to enter the recovery code" />
30
31 5. You are now logged into npm.
32
33 6. (Optional) To disable 2FA, see "[Disabling 2FA][removing-2fa-on-the-web]".
34
35 ### Using recovery code from the command line
36
37 1. Locate the recovery codes generated when you enabled 2FA on your account.
38
39 2. If you are logged out on the command line, log in using `npm login` command with your username and npm password.
40
41 3. Enter an unused recovery code when you see this prompt:
42
43 <Prompt>Enter one-time password:</Prompt>
44
45 4. Once you are logged in, use the below and enter your npm password if prompted.
46
47 ```
48 npm profile disable-2fa
49 ```
50
51 5. Enter another unused recovery code when you see this prompt:
52
53 <Prompt>Enter one-time password:</Prompt>
54
55 6. npm will confirm that two-factor authentication has been disabled.
56
57 7. Follow the steps outlined in "[Configuring two-factor authentication][configuring-two-factor-authentication]" to re-enable 2FA and generate new recovery codes.
58
59 <Note>
60
61 **Note:** Using the recovery codes to re-enable 2FA may create a new authenticator account with the same npm account name.
62
63 If you are using a [time-based one-time password (TOTP)][totp] mobile app and want to delete the old authenticator account, follow the steps for the authenticator.
64
65 </Note>
66
67 ## Viewing and regenerating recovery code
68
69 <Note>
70
71 **Note:** Once you regenerate a set of code, all previous recovery codes become invalid. Each code can be used only once.
72
73 </Note>
74
75 1. <>{shared['user-login'].text}</>
76
77 <>{shared['user-login'].image}</>
78
79 2. <>{shared['account-settings'].text}</>
80
81 <>{shared['account-settings'].image}</>
82
83 3. On the account settings page, under "Two-Factor Authentication", click **Modify 2FA**.
84
85 <Screenshot src="/getting-started/setting-up-your-npm-user-account/2fa-modify.png" alt="Screenshot showing Modify 2FA button" />
86
87 4. Click "Manage Recovery Codes" to view your recovery codes.
88
89 <Screenshot src="/getting-started/setting-up-your-npm-user-account/view-recovery-codes.png" alt="Screenshot showing existing recovery codes and a button to generate set of recovery codes" />
90
91 5. Click "Regenerate Code" to generate a new set of codes.
92
93 ## Misplaced recovery codes
94
95 If you have misplaced both your 2FA device and your recovery codes, you can contact our support team to attempt to recover your account. Provide as much information as possible to help us expedite the request faster.
96
97 1. <>{shared['user-login'].text}</>
98
99 <>{shared['user-login'].image}</>
100
101 2. <>{shared['use-recovery-code'].text}</>
102
103 <>{shared['use-recovery-code'].image}</>
104
105 3. Under the "Use a Recovery Code" form, click **Try recovering your account**.
106
107 4. <>{shared['start-account-recovery'].text}</>
108
109 <>{shared['start-account-recovery'].image}</>
110
111 5. If you have access to your registered email, enter the one-time password sent to your email in the **One-Time Password** field, then click **Verify Email Address**. _If you do not have access to your registered email, select **Skip email verification** at the bottom of the form._
112
113 6. <>{shared['support-ticket-form'].text}</>
114
115 - <>{shared['enter-email-address'].text}</>
116 - In the **How can we help?** section, select **Reset my two-factor authentication (2FA)**.
117 - <>{shared['support-ticket-other'].text}</><>{shared['connect-to-accounts'].text}</>
118
119 <Screenshot src="/getting-started/setting-up-your-npm-user-account/recover-account.png" alt="Screenshot showing existing recovery codes and a button to generate set of recovery codes" />
120
121 7. <>{shared['submit-support-ticket'].text}</>
122
123 [contact-support]: https://www.npmjs.com/support
124 [configuring-two-factor-authentication]: /configuring-two-factor-authentication
125 [setup-recovery-codes]: /configuring-two-factor-authentication#enabling-2fa-on-the-web
126 [removing-2fa-on-the-web]: /configuring-two-factor-authentication#disabling-2fa
127 [using-recovery-code-on-the-web]: /recovering-your-2fa-enabled-account#using-recovery-code-on-the-web
128 [viewing-and-regenerating-recovery-code]: #viewing-and-regenerating-recovery-code
129 [totp]: https://en.wikipedia.org/wiki/Time-based_one-time_password