Auto Lock PC After Failed Logins: How to Set It Up
In this article
Yes, you can set Windows to automatically lock your PC after a specified number of invalid logon attempts. This is a built-in security feature called Account Lockout Policy, and it works by temporarily disabling the account after a configured number of failed password attempts, effectively locking the PC to anyone who doesn't know the correct credentials. You configure it through the Local Security Policy editor (secpol.msc) on Windows Pro, Enterprise, or Education editions, or through a registry tweak on Windows Home.
What the Account Lockout Policy Does
The Account Lockout Policy is part of Windows' security framework. When enabled, it tracks failed sign-in attempts for a specific user account. Once the number of failures reaches the threshold you set, the account is locked for a duration you define. During that lockout, even the correct password will not work. This is a deterrent against brute-force attacks, where an attacker tries many passwords in rapid succession.
It's important to distinguish this from simply requiring a password after sleep or screen timeout. That is a separate setting (dynamic lock, screen saver, or power options). The Account Lockout Policy specifically responds to invalid attempts—wrong passwords or PINs—not to inactivity.
How to Configure It on Windows Pro, Enterprise, or Education
If your PC runs Windows 11 Pro, Windows 10 Pro, or a business edition, the graphical tool is available. Here are the steps:
- Press Win + R, type
secpol.msc, and press Enter. If prompted by UAC, click Yes. - In the left pane, navigate to Account Policies → Account Lockout Policy.
- Double-click Account lockout threshold. Set a number between 1 and 999 (e.g., 5). Click OK.
- Windows will suggest values for the other two settings: Account lockout duration (how long the account stays locked, in minutes) and Reset account lockout counter after (how long after a failed attempt before the counter resets). Accept the suggested values or adjust them.
- Click OK on each dialog, then close the Local Security Policy window.
The settings take effect immediately. You don't need to restart your computer.
How to Configure It on Windows Home
Windows Home edition does not include secpol.msc. You can still achieve the same effect by editing the registry. This is more technical, so follow carefully:
- Press Win + R, type
regedit, and press Enter. - Navigate to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters. - Create or modify three DWORD (32-bit) values. If they don't exist, right-click in the right pane, choose New → DWORD (32-bit) Value and name them exactly as below:
MaxFailedLogons– set to the number of failed attempts before lockout (e.g., 5).LockoutDuration– set to the lockout duration in minutes (e.g., 30).ResetLockoutCounter– set to the time in minutes before the counter resets (e.g., 30).
- Close the registry editor and restart your PC for the changes to take effect.
Be very careful with registry edits—incorrect changes can cause system instability. Back up your registry before proceeding (File → Export).
Choosing the Right Settings
The ideal threshold depends on your environment. A lower number (3–5) provides stronger security but risks locking yourself out if you forget your password or have a typo. A higher number (10–15) is more forgiving but gives an attacker more attempts. For a personal PC, 5 is a common balance. For a corporate environment, administrators often set 3–5 with a 15–30 minute lockout.
Also consider the Reset account lockout counter after setting. This is the time window in which failed attempts count toward the threshold. For example, if the threshold is 5 and the reset is 30 minutes, an attacker who tries 3 times, waits 31 minutes, then tries 3 more times will not trigger a lockout. A shorter reset window (e.g., 15 minutes) is more secure.
Common Problems and Misconceptions
Problem: You lock yourself out. If you enter the wrong password too many times, you'll be locked out. The lockout duration you set applies to everyone, including you. If you set a long duration (e.g., 999 minutes), you'll have to wait or use another admin account to unlock it.
Misconception: The lockout applies to the local account only. Actually, if you use a Microsoft account, the lockout policy applies to the local account that Windows uses to cache credentials. The online Microsoft account itself is not locked by this policy, but the local sign-in is.
Problem: The policy doesn't seem to work. Check that you are using the correct account. The policy applies to local accounts, not to a Microsoft account sign-in that uses a PIN. PIN failures are handled separately by Windows Hello and have their own lockout settings (usually 5 attempts, then a 30-second delay).
Misconception: Locking the PC after failed attempts is the same as encryption. No. Locking prevents access to the desktop, but if your hard drive is not encrypted (e.g., with BitLocker), someone could remove the drive and read data from another machine. For full protection, combine lockout policy with disk encryption.
Alternatives and Additional Measures
If you want a simpler approach without a fixed lockout, consider these options:
- Dynamic Lock: In Windows Settings → Accounts → Sign-in options, you can enable Dynamic Lock, which automatically locks the PC when your paired phone is out of Bluetooth range.
- Screen saver with password: Set a screen saver that resumes to the lock screen. This locks after inactivity, not after failed attempts, but it's a good complement.
- Third-party tools: Some security suites offer more granular lockout settings, but the built-in Windows policy is sufficient for most users.
For organizations, group policy (GPO) can deploy these settings across many computers. The same settings are available under Computer Configuration → Windows Settings → Security Settings → Account Policies → Account Lockout Policy.
Frequently Asked Questions
Does the lockout policy work with a Microsoft account? Yes, but it applies to the local sign-in. If you use a Microsoft account, Windows caches a local account that is subject to the policy. The online account itself is not locked, but the PC will be.
Can I unlock my PC if I lock myself out? Yes. If you have another administrator account, log in with that and reset the lockout by clearing the policy or waiting for the duration. If you have only one account, you may need to wait the lockout duration, or use a password reset disk if you created one.
Does the lockout apply to the PIN or fingerprint? No. Windows Hello has its own separate lockout mechanism. The Account Lockout Policy applies to password attempts only. For PIN, Windows Hello locks after a set number of tries (usually 5) and forces a restart or a longer wait.
Is there a way to see how many failed attempts have occurred? Yes. You can view the Security event log. Open Event Viewer (eventvwr.msc), navigate to Windows Logs → Security, and look for Event ID 4625 (failed logon). This shows the source IP, username, and timestamp.
Will the lockout policy stop a hacker? It deters casual brute-force attacks, but a determined attacker could still try other methods like phishing or exploiting software vulnerabilities. It is one layer of defense, not a complete solution.