Home > Unlock Bootloader

Fix Relock Bootloader/TWRP Fastboot: Error: Command Failed

UPDATE: Added a new section at the end of this guide to fix Fastboot: Error: Command Failed when trying to install the TWRP Recovery. The below article pertaining to this error while relocking the bootloader continues…


In this guide, we will show you the steps to fix the issue of being unable to relock the bootloader on Android and instead getting Fastboot: Error: Command Failed error. While stepping into the custom development brings in a plethora of goodies with itself, but on the flip side, it also paves the way for the entrance of a few bugs and issues. From SafetyNet getting tripped to banking apps not working and Widevne L1 being downgraded to L3, there are quite a few caveats attached to it.

cannot relock bootloader Fastboot: Error: Command Failed

Combine all these factors and we could clearly see why many users wish to revert to the stock ecosystem sooner than later. However, that is proving to be easier said than done for many. Numerous users have voiced their concern that they are unable to relock the bootloader on their Android devices and instead getting Fastboot: Error: Command Failed error. If you are also facing the same issue, then this guide will help you out. Follow along for the fix.

Fix Cannot Relock Bootloader on Android- Fastboot: Error: Command Failed error

relock bootloader Fastboot- Error- Command Failed

It goes without saying that before you relock the bootloader, your device has to be completely stock. And by that, we don’t only mean stock firmware, instead, it should not have any traces of custom binary as well. Even if one single file related to a module is left behind, then your device will prevent you from relocking the bootloader [which in fact is great otherwise your device would have gotten hard-bricked].

While generally flashing the Fastboot ROM for your device should be more than sufficient, but just to be double sure, it’s recommended that you first remove all the modules, unroot your device, and then only flash the Fastboot ROM. Moreover, if given a choice, never choose the option to relock the bootloader while the flashing is going on. Instead, do so after the flashing is over and you are booted to the OS.

STEP 1: Remove Modules

  1. Launch Magisk, go to Modules, and tap on Remove next to each module.Relock Bootloader Android Fastboot: Error: Command Failed
  2. Along the same lines, disable and remove all the LSPosed modules as well.
    relock bootloader Fastboot: Error: Command Failed
  3. Likewise, uninstall any third-party mods present on your device.
  4. Once done, restart your device for the changes to take place.

STEP 2: Unroot Device

  1. Launch Magisk, tap on Uninstall, and select Complete Uninstall.
  2. Then wait for the process to complete and tap on Reboot.cannot relock bootloader Fastboot: Error: Command Failed

STEP 3: Flash Stock Firmware

Now comes the all-important question- how to flash the firmware? Well, the process varies depending on the device that you own. Here are some of the most noteworthy ones [do note that irrespective of the method you opt for and the device you own, the process will wipe off all the data on your device, so please take a backup beforehand].

relock bootloader Fastboot: Error: Command Failed error

Pixel: Android Flash Tool
OnePlus: Fastboot Enhance Tool | MSM Download Tool
Xiaomi/Redmi/Poco: Mi Flash Tool
Samsung: Frija Tool

STEP 4: Relock the Bootloader

Once you are booted to the OS after flashing the stock firmware, you could now relock the bootloader on your device using the detailed instructions given in this guide. Or, in short, just execute either of the two below commands [with your device booted to Fastboot Mode]:

relock bootloader Fastboot: Error: Command Failed

fastboot flashing lock
fastboot oem lock

That’s it. These were the steps to fix the issue of being unable to relock the bootloader on your Android device and instead getting Fastboot: Error: Command Failed. If you have any queries concerning the aforementioned steps, do let us know in the comments. We will get back to you with a solution at the earliest.

Fix TWRP Fastboot: Error: Command Failed

TWRP Fastboot- Error- Command Failed

You might also get bugged by the Fastboot: Error: Command Failed while trying to flash the TWRP Recovery. In that case, you could refer to our below-listed tweaks:

FIX 1: Check File Name

First off, make sure that the name of the recovery is the same that you have typed in the CMD window.

FIX 2: Verify TWRP Location

Next up, verify that the recovery file is placed inside the platform-tools folder.

FIX 3: Choose between Recovery and Boot Partition

Check if your device has a recovery partition or not. If it has one, then you could directly flash TWRP to its recovery partition via fastboot flash recovery recovery.img. However, if there’s no recovery partition, you’ll have to use the boot partition via fastboot boot recovery.img. Once booted, you could then permanently install it [optional] by flashing the recovery ZIP via the Install section or the recovery IMG file via Advanced > Ramdisk.

TWRP Fastboot- Error- Command Failed

FIX 4: Manually Specify Slots

Finally, consider manually specifying the slots as well. For instance, instead of fastboot flash recovery recovery.img, you could use fastboot flash recovery_a recovery.img and fastboot flash recovery_b recovery.img.


Share: