Xiaomi’s 20 digit security code: where to find, how to restore, and what to do when you make mistakes

Have you faced a requirement to enter a 20-digit Xiaomi security code but don't know where to look?This situation is familiar to many owners of Xiaomi, Redmi or POCO devices - especially after resetting, updating firmware or linking to a new Mi Account.The code may be required to unlock the bootloader, confirm ownership or restore access to the Find Device feature.

Unlike the standard ones. PIN-For codes or graphics keys, this code is not stored in the device's memory in a clear form (IMEI) In this article, we will discuss all the official and alternative ways to obtain code, and explain why some methods stopped working after Xiaomi’s security policy updates in 2023-2026.

What is a 20 digit security code and why you need it?

The 20-digit code is a unique hardware and software identifier that Xiaomi uses to:

  • πŸ”’ Confirmation of ownership of the device when resetting or flashing.
  • πŸ“± Unlock the bootloader (Bootloader Unlock) for installing custom firmware.
  • πŸ”„ Restore Find Device or Mi Cloud features after a change SIM-map.
  • πŸ›‘οΈ Protection against theft: the code is tied to IMEI and account, which makes it difficult to use the device after resetting.

Until 2022, the code could be obtained via SMS or email, but after tightening security policy, Xiaomi switched to automatic code generation in the personal account.

⚠️ Note: If you bought the device with your hands, the security code may have been reset by the previous owner, in which case it can only be restored through Mi Support with the confirmation of the purchase check.

Where to find security code on Xiaomi devices

The location of the code depends on the device type and version of MIUI. Below are the current ways for Xiaomi smartphones, tablets and TVs.

πŸ“± On smartphones and tablets (MIUI 12–14)

If the device is not locked and you have access to the settings:

  1. Open the Settings. β†’ The phone.
  2. Tap 5-7 times on the MIUI version line to activate the developer mode.
  3. Back to Settings β†’ Additionally. β†’ For developers.
  4. Find Mi Unlock Status – this may show the code or a link to get it.

If there is no item, try an alternative path:

  • πŸ“Œ Go to Settings. β†’ Xiaomi account β†’ Security.
  • πŸ“Œ In the Devices section, select the current gadget – sometimes the code is displayed in detail.

β˜‘οΈ Checking before requesting code

Done: 0 / 4

πŸ“Ί On Xiaomi TVs (MIUI TV)

For Xiaomi Mi TV, Redmi Smart TV or Mi Box:

  1. Press the Menu + Volume Down buttons on the 5 seconds remote to open the service menu.
  2. Select Device Preferences β†’ About β†’ Status.
  3. Scroll to the Security Code section – if the code is not displayed, you need to request it through your personal account.

Important: On TVs, the code may be called Mi TV Authorization Code, and it's 16 to 20 characters long, and if the screen is locked, the only way to get in touch with support is to get in touch with it.

πŸ•ΆοΈ On smart watches and bracelets (Mi Band, Watch)

For wearable Xiaomi devices, a security code is not usually required, but if a request appears when reset:

  • πŸ”— Connect the watch to the Mi Fitness or Zepp app.
  • πŸ”— Go to Profile. β†’ Devices β†’ [Your model] β†’ Security settings.
  • πŸ”— The code can be generated automatically when you first connect.

⚠️ Note: On devices with Mi Band 7 Pro and newer, the security code has been replaced by QR-The authentication code that's generated in the application. It can't be entered manually!

How to request a security code through official channels

If the code doesn't show up in the settings, it can only be accessed through official Xiaomi services. Here are the current ways for 2026:

🌐 Through the personal account Mi Account

  1. Go to account.xiaomi.com and log in.
  2. Select the Devices tab.
  3. Find the device in the list and click Details.
  4. In the Security section, the button will be Get Security Code.

Limitations:

  • ⏳ Code is generated within 24–72 hours (depending on the region).
  • πŸ“ The device must be linked to the account for at least 7 days.
  • πŸ”„ If the device was reset, the code may not be generated – a confirmation of purchase will be required.

πŸ“§ Xiaomi (Mi Support) Support)

If the code does not come in the personal account:

  1. Write in support chat or email support@xiaomi.com.
  2. Indicate: πŸ†” IMEI Devices (can be found on the box or via *#06#). πŸ“„ Purchase check number (required for devices purchased less than 3 months ago). πŸ” Reason for request (e.g., β€œrequired to unlock the bootloader").

3-5 working days

From 2026, Xiaomi requires a purchase confirmation to generate code on devices older than 2 years.

πŸ“Š What kind of code you have tried?
Through the personal account Mi Account
Through Xiaomi Support
Found it in the device settings.
I haven't tried it yet.
Another way.

Frequent mistakes and how to fix them

When you're working with security code, you're going to have a problem with the most common ones.

Mistake.Reason.Decision
Invalid Security CodeThe code is incorrect or outdated.Request a new code in your personal account. The old codes only last 30 minutes.
Device Not BoundThe device is not linked to the Mi Account.Tie the device through Settings β†’ Xiaomi Account and wait 24 hours.
Too Many AttemptsExceeded the number of attempts to enter.Wait 24 hours or drop attempts through your personal account.
Region LockThe device is locked to another region.Use a VPN for your country of purchase or contact support with a check.

If the device is locked after reset and requires a code but you don’t know it:

  • πŸ”„ Try to enter the last used PIN-Mi Account Code or Password.
  • πŸ“ž Contact the previous owner (if the device is purchased by hand).
  • πŸ“„ Provide Xiaomi with a purchase check in support – they can reset the lock.
What if the code does not come to the email?
Check the Spam folder, Xiaomi emails often get there, and make sure that the email linked to the Mi Account is confirmed. If the email hasn't arrived within 48 hours, write support with the IMEI device.

Alternative methods (at your own risk)

The official methods don’t always work, especially for older devices, and below are some unguaranteed ways that may help, but involve risks:

πŸ”§ Through the Engineering Menu (for experienced users only)

On some devices, code can be extracted through Engineering Mode:

  1. Type on the keyboard ##4636##.
  2. Go to Engineering Mode β†’ Device Information β†’ Security.
  3. Find the Security Code or Auth Code.

Risks:

  • ⚠️ This method does not work on new devices (c). MIUI 13+ lock-in).
  • ⚠️ Incorrect actions can lead to a complete locking of the device.

πŸ’» Through ADB-commands (unlocked loader required)

If you have access to ADB:

adb shell


su




cat /data/data/com.xiaomi.finddevice/files/.security_code

This command will output the code if it's stored in the file system. It only works on root-righted devices!

πŸ’‘

If you buy Xiaomi with your hands, be sure to ask the seller to untie the device from its Mi Account and reset the security code. Otherwise, you may lose access to the features after resetting.

How to protect your device from locking

To avoid future security code issues:

  • πŸ” Link the device to your Mi Account immediately after purchase.

If you plan to sell or transfer the device:

  1. Reset via Settings β†’ Reset settings β†’ Delete all data.
  2. Untie the device from the Mi Account in your personal account.
  3. Make sure the new owner can log in without asking for a code.

πŸ’‘

The only reliable way to avoid security code issues is to link the device to your Mi Account immediately after purchase and save all documents.

FAQ: Frequent questions about Xiaomi's security code

πŸ”Ή Can I reset the security code without a purchase check?
No. From 2023, Xiaomi requires proof of purchase to reset code on devices older than 1 year.
πŸ”Ή How long does the generated code last?
The code is valid for 30 minutes from generation, and after that time, you need to request a new one.
πŸ”Ή Why the code doesn’t come to email?
Check: Spam folder in the mail, correctness of the attached email in Mi Account, no VPN (it can block sending) If the email did not arrive within 48 hours, contact support.
πŸ”Ή Can I use the code from another device?
No. The code is tied to a specific IMEI and account, and it's not going to work on another phone or tablet.
πŸ”Ή What to do if the device is locked after resetting?
The only options are: Enter a security code (if you have one), contact Xiaomi with a check for a purchase; if the device is bought from hand, try contacting the previous owner; a self-reset via Recovery or Fastboot will not help - locking the hardware.