How to Add a Passcode to an iPhone

A passcode is the most important security setting on your iPhone. It locks the screen, encrypts your data, and is required for Face ID, Touch ID, Apple Pay and many security features. This guide shows how to add a passcode, choose a stronger custom code, change how quickly it’s required, and what to do if you forget it. The steps apply to current iPhones and older models like the iPhone 5.

Quick Answer

Open Settings > Face ID & Passcode (or Touch ID & Passcode, or just Passcode on older models). Tap Turn Passcode On, enter a six-digit passcode, and enter it again to confirm.

Phone Face ID and Passcode settings with the Turn Passcode On option highlighted
Tap Turn Passcode On to set a passcode.

How to Add a Passcode

  1. Open Settings.
  2. Tap Face ID & Passcode, Touch ID & Passcode or Passcode, depending on your model.
  3. Tap Turn Passcode On.
  4. Enter a six-digit passcode. To choose a different type, tap Passcode Options first.
  5. Enter the passcode again to confirm.
  6. If asked, enter your Apple Account password.

Choose a Stronger Passcode

Tap Passcode Options when creating or changing the passcode:

  • Custom Alphanumeric Code: letters and numbers, the most secure option.
  • Custom Numeric Code: any number of digits longer than six.
  • 4-Digit Numeric Code: easier to type but much easier to guess. Not recommended.

Avoid birthdays, repeated digits (111111) and sequences (123456).

Set Up Face ID or Touch ID

After setting a passcode, tap Set Up Face ID or Add a Fingerprint on the same screen. You’ll still need the passcode after restarting, after 48 hours without unlocking, and for some security changes.

Change When the Passcode Is Required

  1. In Face ID & Passcode, tap Require Passcode.
  2. Choose Immediately for the best security. Longer delays are only available if Face ID or Touch ID is off.

Other Security Options on This Screen

  • Allow Access When Locked: turn off items like Control Center, Reply with Message, or USB Accessories to limit what someone can do without unlocking.
  • Erase Data: erases the iPhone after 10 failed passcode attempts. Use with care and keep backups.
  • Stolen Device Protection (iOS 17.3 and later): adds Face ID or Touch ID requirements and a security delay for sensitive changes away from familiar locations.

Change or Turn Off the Passcode

  • Change: Face ID & Passcode > Change Passcode, enter the old code, then the new one.
  • Turn off: Face ID & Passcode > Turn Passcode Off. This also disables Face ID, Apple Pay and some data protection, so it isn’t recommended.

On iOS 17 and later, after changing your passcode you can use the old one for 72 hours if you forget the new one (tap Forgot Passcode? > Enter Previous Passcode).

Forgot Your Passcode?

  • After several wrong attempts, iPhone shows iPhone Unavailable or Security Lockout. On iOS 15.2 and later with an internet connection, tap Forgot Passcode? (or Erase iPhone) and enter your Apple Account password to erase it.
  • Otherwise, use a computer and recovery mode to erase the iPhone.
  • Erasing removes all data; restore from an iCloud or computer backup afterward.

For extra security, switch to an alphanumeric passcode.

Frequently Asked Questions

Does a passcode encrypt my iPhone?

Yes. Setting a passcode turns on Data Protection, which encrypts your data with a key tied to the passcode.

Why can’t I turn the passcode off?

A work or school profile, Screen Time restriction or Stolen Device Protection may require it.

Can I use the same steps on iPad?

Yes. The settings are the same on iPad.

Summary

  1. Settings > Face ID & Passcode.
  2. Tap Turn Passcode On.
  3. Use Passcode Options for a stronger code.
  4. Set Require Passcode to Immediately and set up Face ID or Touch ID.