Privacy & security

Forgot Your iPhone Passcode? Try the Old Code Before Erasing

The short answer

If you changed the passcode within 72 hours on iOS 17 or later, check Forgot Passcode? for an option to enter the previous code. If that option is unavailable and you cannot unlock the phone, Apple's reset methods erase the iPhone. Check your Apple Account access and existing backups before erasing.

Related sourcesApple

01Try the previous passcode first

Section link

On the iPhone Unavailable screen, tap Forgot Passcode? and choose Enter Previous Passcode if it appears. Enter the code you used just before the change, then set a new one. If you already expired the old code, it will no longer work. The Forgot Passcode? option requires a network connection and Find My to be enabled.

02Check what you can recover before erasing

Section link

Make sure you can sign in to the Apple Account linked to this iPhone. You may need it to activate the device again. Check whether you have an iCloud or computer backup and when it was made. Data stored only on the phone and missing from your backup will be lost when you erase it.

03Erase from the lock screen if the option is available

Section link

On iOS 17 or later, go from Forgot Passcode? to Start iPhone Reset. Enter the linked Apple Account password and confirm the erase. If prompted about your eSIM, keep it if you plan to use the same line. On eligible older versions starting with iOS 15.2, look for Erase iPhone on the lock screen. If you use an eSIM on an older version, ask your carrier about reactivation before erasing.

04Use a Mac or Windows PC if you cannot erase on the phone

Section link

Turn off the iPhone and follow Apple's recovery-mode instructions for your model. Keep holding the specified button until the cable and computer image appears. In Finder on Mac or Apple Devices on Windows, select the iPhone and choose Restore. If the phone leaves recovery mode during the download, let the download finish and enter recovery mode again.

05Choose your backup during setup

Section link

At the Hello screen, start setup and select your iCloud or computer backup if you have one. Check the backup date so you know how recent the restored data will be. If a secondhand phone asks for the previous owner's account, ask the seller to remove it from that account.

Sources & further reading