Bypass a Forgotten Android PIN with ADB (No Root)

9 min read Learn a safe, step‑by‑step method to remove a forgotten Android PIN with ADB when USB debugging is already enabled, without rooting or data loss. October 13, 2026 21:00 How to Bypass a Forgotten Android PIN Using ADB (No Root)

Why the PIN Can Be Cleared with ADB

Android stores the lock‑screen PIN in a protected system database that is only accessible to privileged processes. When USB debugging is enabled, the adb daemon runs with the same privileges as the system UI, allowing it to invoke the locksettings service. The command adb shell locksettings clear --old <old‑pin> tells the service to forget the stored PIN, effectively resetting the lock screen.

This works only if the device already trusts the computer (the RSA key is authorized) and the user has previously enabled developer options. If those conditions are not met, the method cannot be used – the device will remain locked and a factory reset may be the only option.

Before You Start

  • USB debugging must be enabled on the locked device (Settings ▶ Developer options ▶ USB debugging).
  • The computer you will use must be already authorized on the phone. If you never connected the phone to this PC before, the method will not work.
  • Install the latest Android Platform‑Tools (ADB) on your PC or Mac.
  • Charge the phone to at least 50 % to avoid accidental shutdown during the process.
  • Back up any data you can still access (e.g., SD card, cloud services) before proceeding.
Warning: Clearing the PIN does not erase user data, but it does reset all credential‑based security (fingerprint, face unlock, Smart Lock, etc.). Encrypted files that rely on the PIN for key derivation may become inaccessible.

Step‑by‑Step Procedure

1. Connect the Phone to Your Computer

  1. Use a good‑quality USB‑C or micro‑USB cable.
  2. Plug the phone into a USB port on the computer.
  3. On the computer, open a terminal (Command Prompt, PowerShell, or a macOS/Linux shell).

When you run adb devices you should see the device listed as device. If it shows unauthorized, the phone is not trusting this computer – you cannot continue.

2. Verify ADB Connection

adb devices

Expected output:

List of devices attached
1234567890abcdef    device

If the list is empty or shows offline, try a different cable, enable USB‑debugging again (if you can access Settings), or restart the adb server with adb kill-server && adb start-server.

3. Issue the PIN‑Clear Command

Run the following command, replacing <old‑pin> with the PIN you think you set. If you are unsure, you can try common PINs (1234, 0000) – the command will simply fail without locking the device further.

adb shell locksettings clear --old <old‑pin>

When successful, you will see no output (just a new prompt). The device’s lock‑screen database is now cleared.

4. Reboot the Phone

Although a reboot is not strictly required, it guarantees the UI picks up the change.

adb reboot

The phone will restart. After it powers on, the lock‑screen will no longer ask for a PIN.

5. Set a New PIN (Optional but Recommended)

  1. Swipe up to unlock the device (no PIN required).
  2. Open Settings ▶ Security ▶ Screen lock.
  3. Choose PIN and follow the prompts to create a new, memorable PIN.

Re‑enabling a PIN restores the protection you had before.

Alternative Path: Using Fastboot When USB Debugging Is Not Enabled

If USB debugging was never turned on, the ADB method cannot be used. In that case you can try the fastboot erase userdata command, but be aware it will erase all user data on the device.

  1. Power off the phone.
  2. Boot into fastboot mode (usually Power + Volume Down).
  3. Connect to PC and run fastboot erase userdata.
  4. Reboot with fastboot reboot.

This method is a last resort when the device is completely inaccessible.

Troubleshooting Common Issues

  • ADB reports "device unauthorized"
    • Disconnect and reconnect the cable.
    • On the phone, look for the RSA‑key prompt and tap Allow. If the prompt never appears, the device’s USB debugging setting may have been disabled by the lock screen – you cannot proceed.
  • Command returns "SecurityException"
    • This means the ADB shell does not have the required permission. Verify that the device is running Android 7.0 or newer (the locksettings service was hardened in later releases).
    • On some OEM skins (e.g., Samsung One UI), the command is adb shell locksettings clear --old <old‑pin> --user 0.
  • Phone restarts but still asks for PIN
    • Make sure you entered the exact PIN. A typo will cause the command to fail silently.
    • Some devices store the PIN in the hardware‑backed keystore; on those models the ADB method is blocked. In that case, only a factory reset will work.

When This Method Won’t Work

The ADB PIN‑clear relies on two conditions:

  1. The device trusts the computer (RSA key authorized).
  2. USB debugging is still enabled in the system settings.

If either condition is missing, Android treats the device as a security‑critical environment and refuses the locksettings call. Newer Android versions (10+ on many OEMs) also add a "device‑policy‑manager" check that blocks the command when the device is managed by a corporate profile.

Best Practices to Avoid Future Lock‑outs

  • Write down your PIN in a secure password manager.
  • Enable Smart Lock (trusted places, devices, or face) as a fallback.
  • Periodically verify that USB debugging is still enabled if you rely on ADB for recovery.
  • Consider setting a secondary unlock method (pattern, password) that you find easier to remember.

Wrap‑Up

By following the steps above you can safely clear a forgotten Android PIN using ADB, provided the device already trusts your computer and has USB debugging enabled. This approach avoids a full factory reset, preserving your apps and data while restoring access to the device. Always keep a backup of your PIN or enable alternative unlock methods to prevent future lock‑outs.

User Comments (0)

Add Comment
We'll never share your email with anyone else.