If you are trying to flash a custom ROM or update your device via Fastboot and encounter the error FAILED (remote: 'flashing lock flag is locked. please unlock it first'), it means your device's bootloader is currently locked.
Modern Android security prevents unauthorized software changes unless the "lock flag" is explicitly flipped by the user. Here is how to fix this and successfully unlock your device. 1. Enable OEM Unlocking
You cannot unlock the bootloader through a computer alone; you must first give the phone permission from within the Android OS. Open Settings > About Phone.
Tap Build Number 7 times until you see "You are now a developer". Go back to System > Developer Options. Find OEM Unlocking and toggle it ON.
Also, enable USB Debugging to allow the computer to send commands. 2. Enter Fastboot Mode
The "flashing lock" error only appears when you are in Fastboot (Bootloader) mode. To get back there after enabling the settings above:
Via ADB: Connect your phone to your PC and run:adb reboot bootloader
Via Buttons: Power off the device, then hold Power + Volume Down (common for most devices) until the Fastboot logo appears. 3. Run the Unlock Command
Once the device is in Fastboot mode and connected to your PC, use the following commands. Warning: This will perform a factory reset and erase all data on your device.
Try the modern standard command first:fastboot flashing unlock If you are trying to flash a custom
If you receive an "unknown command" error, try the legacy command:fastboot oem unlock 4. Confirm on the Device
After sending the command, your phone screen will likely change to a confirmation page. Use the Volume Buttons to highlight "Unlock the Bootloader" and the Power Button to confirm. The device will then wipe itself and reboot. Troubleshooting Common Issues
The error message "FAILED (remote: 39: flashing lock flag is locked. Please unlock it first)"
indicates that you are attempting to flash firmware or modify system partitions while your device’s bootloader is locked
. To protect system integrity, Android devices prevent unauthorized software changes unless this lock is explicitly removed. Common Fixes for this Error
To resolve this, you must unlock the bootloader through your device settings and a series of commands. Unlocking the bootloader typically erases all data on the device. Enable Developer Options & OEM Unlocking On your phone, go to Settings > About Phone Build Number seven times until "Developer mode" is enabled. Settings > System > Developer Options OEM Unlocking USB Debugging Use Fastboot Commands Connect your phone to your computer in Fastboot Mode (usually by holding Power + Volume Down during boot).
Open a command terminal on your PC and try one of the following commands based on your device manufacturer: fastboot flashing unlock fastboot oem unlock
Check your phone screen for a confirmation prompt and use the volume keys to select "Yes" or "Unlock." Manufacturer-Specific Codes (Motorola, Xiaomi, etc.) Some brands, like
, require you to request a unique "Unlock Key" from their official support site using a string generated by the fastboot oem get_unlock_data Root Cause Analysis (example scenarios)
devices often require using the official Mi Unlock Tool after a waiting period linked to your Mi account. Why is this happening? Security Protection
: The "lock flag" is a security feature that ensures only official, signed software can be installed. Incorrect Command : You might be trying to flash an image ( fastboot flash recovery recovery.img ) without first running the unlock sequence.
If you are just trying to get your phone to boot normally and it is stuck on this screen, try selecting Normal Boot from the Fastboot menu using the volume and power buttons. specific unlocking steps for a certain phone brand like Motorola or Xiaomi?
Lock and unlock the bootloader | Android Open Source Project
failed - remote 39 - flashing lock flag is locked. please unlock it first
A: In most regions, yes. Manufacturers consider unlocking the bootloader as a warranty-voiding action, though some (like OnePlus and Google) allow it with caveats.
This error occurs when you try to perform an operation (e.g., flashing firmware, writing data, or modifying a device) while the device’s flash lock flag is enabled. The “39” likely refers to a specific error code from the tool or device firmware.
The flashing lock flag is a safety mechanism that prevents accidental overwriting or corruption of critical memory regions. It must be explicitly unlocked before any write/flash operation can proceed.
The "failed -remote 39 — flashing lock flag is locked" error indicates a lock preventing flash writes. Rapid resolution requires determining whether the lock is reversible; use vendor unlock procedures when available, update tooling, and implement pre-flash checks and controls to prevent recurrence. Online forums (e.g.
Use the standard fastboot flashing unlock command.
Steps:
Reboot to bootloader:
adb reboot bootloader
Unlock the flashing lock flag:
fastboot flashing unlock
A prompt will appear on your device screen. Use volume keys to select "Unlock the bootloader" and press power to confirm.
The device will wipe data and reboot. Verify unlock status:
fastboot getvar unlocked
Expected output: unlocked: yes
If you still see the error, try the legacy command:
fastboot oem unlock