If you forgot your iPhone passcode but changed it in the last 72 hours on iOS 17 or later, tap Forgot Passcode? and choose Enter Previous Passcode to get in without losing data, unless the old code was expired early. Otherwise erase the iPhone with Forgot Passcode?, Find My or a computer in recovery mode, then restore a backup during setup.
Apple is blunt about the erase routes: without the previous passcode, getting into an iPhone after you forget the code means resetting the device, and that deletes what is on it. So the most useful ten minutes you can spend is checking what your backup and iCloud already hold. This guide is about the screen passcode. A forgotten Apple Account password has its own section below, and a carrier lock is a different job that Apple says only your carrier can do.
The short version
- Changed the code in the last 72 hours on iOS 17 or later: tap Forgot Passcode?, then Enter Previous Passcode. Nothing is erased.
- Otherwise, on the iPhone: Forgot Passcode?, Start iPhone Reset, your Apple Account password, then Erase iPhone.
- No Forgot Passcode? button: erase it with Find My from another device, or use a Mac or PC in recovery mode.
- Afterwards: restore your backup during setup. Anything that was only on the phone is gone.
- Face ID still works: don't restart or update the iPhone, and back it up before anything else.
Choose the way back in that fits your iPhone
Apple gives the routes in a fixed order: try the previous passcode first, then the reset on the iPhone itself, and use a computer only if neither works. Find My is a fourth way to start the same erase from another device. The table shows what each one needs and whether your data survives.
| Your situation | Use this route | What it needs | Your data |
|---|---|---|---|
| You changed the passcode in the last 72 hours | Forgot Passcode? then Enter Previous Passcode | iOS 17 or later and the old passcode | Kept |
| Forgot Passcode? (or Erase iPhone on iOS 15.2 and 16) appears on the lock screen | Reset on the iPhone | iOS 15.2 or later, Find My turned on, a network connection, your Apple Account password | Erased |
| Find My was on and you have another device or a browser | Erase This Device in Find My | Your Apple Account sign-in | Erased |
| None of the above works | Recovery mode and Restore | A Mac or Windows PC, a cable and internet | Erased |
| The erased iPhone asks for an Apple Account | Activation Lock sign-in | The account that was on the iPhone | Already erased |
This guide sticks to Apple's own routes and leaves out paid unlock tools. Apple says an iPhone checks Activation Lock with Apple every time it is activated or recovered. So if Find My was on, expect an iPhone erased with Find My or a computer to ask for the Apple Account that was signed in on it, while the reset on the iPhone itself asks for that password before it erases.
If Face ID still unlocks your iPhone
Some people forget the code while Face ID still lets them in. Treat that as borrowed time. Apple says you must always enter the passcode after the iPhone is turned on or restarted, when it has not been unlocked for more than 48 hours, and after five failed Face ID attempts. Apple also lists updating the software as something that needs the passcode, so leave updates alone for now.
The power-off screen counts too. On our iPhone 17 Pro with iOS 26.6, we opened it by touching and holding the power icon in Control Center, tapped Cancel without sliding, and the iPhone asked for the passcode before Face ID would work again. A single tap on that icon did nothing.
While Face ID still works, make a fresh backup. Apple's steps are to connect to Wi-Fi, open Settings, tap your name, then iCloud, iCloud Backup and Back Up Now, and stay on Wi-Fi until it finishes. Face ID will not let you set a new code, because Apple says changing passcode settings needs the current passcode. A completed backup can restore what it holds, but check the synced data below before you erase.
Check what you will get back before you erase
Apple says a computer reset erases the data currently on your iPhone, and the on-device and Find My routes delete everything too. What comes back afterwards depends on two things that happened before the lockout: a backup, and iCloud syncing. Anything that reached neither is gone.
You can check the backup from another iPhone or iPad signed in to the same Apple Account. Open Settings, tap your name, then iCloud and iCloud Backup. The last successful backup under Back Up Now belongs to the device in your hand, not the locked one. On our iPhone the All Device Backups list below it held a second device as well as This iPhone.
Tap the locked iPhone's name in that list to open its own backup. Apple lists the last backup among a backup's details, so check that date before you erase, not the one at the top of the pane.
If you back up to a computer instead, look there before you erase. Our guide shows how to find your iPhone backups on a Mac, so you can see whether one exists before anything is erased.
Synced data is the second safety net. Apple says photos in iCloud Photos upload to iCloud and are not part of your nightly backup, and the same goes for texts when Messages in iCloud is on. On our iPhone those switches read Sync this iPhone under iCloud Photos and Use on this iPhone under Messages in iCloud.
If you are not sure the photos were syncing, access your iCloud Photos on the web from a computer and see whether the recent ones are there. With Messages in iCloud off, Apple says your texts and attachments go into the next iCloud Backup instead, and notes saved only on the iPhone are included in the backup as well.
Try your previous passcode first
Apple's Passcode Reset is the one route that keeps everything. When you change your passcode on iOS 17 or later, the old one keeps working for up to 72 hours, without a computer and without a reset. Apple adds that you are asked to set a new passcode straight away when you get in this way.
Apple's steps are to keep entering a passcode until the iPhone Unavailable screen appears, then tap Forgot Passcode? in the bottom corner. Tap Enter Previous Passcode, type the old code and follow the prompts to choose a new one.
Stop guessing as soon as the Forgot Passcode? option appears. Apple's own pages disagree on whether the lockout comes after four or five wrong tries, and if Erase Data is turned on, Apple says the iPhone erases itself after ten failed attempts. Without that setting, Apple's passcode page says ten failed attempts mean the iPhone has to be restored with a computer, so use the on-screen reset as soon as it appears instead of trying more codes.
If Enter Previous Passcode is missing, the change may be more than 72 hours old, or someone may have tapped Expire Previous Passcode Now, which Apple says ends the window early. Apple also says Forgot Passcode? appears only when the iPhone is connected to a cellular or Wi-Fi network, signed in to an Apple Account and has Find My turned on.
Reset your iPhone from the lock screen
The on-device reset needs no computer, but Apple lists four things it does need: iOS 15.2 or later, Find My turned on before the lockout, an active cellular or Wi-Fi connection, and your Apple Account and password. The password matters most, because the iPhone uses it to sign out of your account before the erase.
Apple's steps on iOS 17 or later start at the lock screen. Enter a passcode until iPhone Unavailable appears, then tap Forgot Passcode?. On the Security Lockout screen, tap Start iPhone Reset and enter your Apple Account password when asked.
Then tap Erase iPhone, which Apple says permanently deletes all of your data and settings. If you use an eSIM, iOS 17 or later lets you keep the eSIM and erase your data, or delete the eSIM along with everything else.
On iOS 15.2 and iOS 16 the button on the lock screen reads Erase iPhone instead of Forgot Passcode?, and if you use an eSIM there, Apple says to ask your carrier for a QR code to set it up again before you start. When the iPhone restarts, set it up, restore a backup if you have one and choose a new passcode.
Erase it remotely with Find My
If the iPhone never shows Forgot Passcode? but Find My was turned on before the lockout, you can start the same erase from somewhere else. Apple's web route is to sign in at icloud.com/find, select the iPhone in the list of devices, choose Erase This Device and follow the prompts. Our guide on how to use Find My iPhone on a computer walks through that page.
On another iPhone signed in to the same Apple Account, Apple's steps are to open Find My, tap Devices, tap the name of the locked iPhone, then Erase and Continue. You confirm with your Apple Account password. Apple says the Find My app can't erase a device remotely without two-factor authentication on the account, so use the website if that is the case.
The locked iPhone does not need to be online when you send the request. Apple says an offline device shows Erase Pending and the erase begins the next time it connects to Wi-Fi or cellular. Apple also sends a confirmation email to your Apple Account address, and Activation Lock stays on, so keep your password ready for setup.
Reset it with a Mac or Windows PC
This is Apple's last resort, and it works when nothing on the iPhone itself does. Apple lists a Mac or Windows PC, a cable that could charge the iPhone, an internet connection and up to 60 minutes. Like the other routes, it erases the data currently on the iPhone.
Turn off the iPhone and start recovery mode
Disconnect the iPhone from the computer first. On an iPhone with Face ID, Apple says to press and hold the side button and the volume down button until the sliders appear, then let go and drag the power off slider. Apple warns that holding both buttons on starts the Emergency SOS countdown, and when it ends the iPhone calls emergency services. On an iPhone with a Home button, hold the top or side button instead.
Connect the cable to the computer, then plug it into the iPhone while you quickly hold the button for your model. Keep holding through the Apple logo and let go only when an image of a computer and a cable appears. If the buttons don't respond and that image never shows, Apple says the iPhone might need service.
Recovery mode is not the same as a force restart. A force restart only restarts the iPhone, and Apple says a restarted iPhone always asks for the passcode, so it won't get you in. Our guide on how to force restart an iPhone covers that button sequence for a frozen screen.
Restore on a Mac or Windows PC
On a Mac, open a Finder window and select the iPhone in the sidebar under Locations, allowing the accessory to connect if asked. When you get the choice to Restore or Update, select Restore, as Apple instructs, not Update.
On Windows, Apple's passcode steps use the Apple Devices app from the Microsoft Store. Select the iPhone in the sidebar, choose to trust it if asked, select General, then Restore, and follow the prompts.
The computer may need to download iOS first, and Apple warns this can take more than 15 minutes. If the iPhone leaves the recovery screen while it waits, let the download finish, turn the iPhone off and start recovery mode again. When the Hello screen appears, disconnect the iPhone and set it up. With no computer of your own or one to borrow, Apple sends you to an Apple Store or an Apple Authorized Service Provider.
Set up your iPhone and restore a backup
Follow the setup screens until Transfer Your Apps & Data, then tap From iCloud Backup and sign in. Apple says to look at the date and size of each backup and pick the most relevant one. Our guide on how to restore your iPhone from a backup covers the iCloud and computer routes step by step.
Stay on Wi-Fi while the progress bar runs, which Apple says can take from a few minutes to an hour. Apps, photos and music keep restoring in the background for hours or even days, so leave the iPhone on Wi-Fi and power as often as you can.
Don't set the iPhone up as new with a plan to restore later. Apple warns that if you do, the new iCloud backups the iPhone makes can overwrite your earlier ones. Restore during setup, or erase again soon and restore before that happens.
For a computer backup, open Finder or Apple Devices, select the iPhone, choose Restore Backup and pick the backup by date. Apple says you will need the password if the backup was encrypted. If your texts were in that backup rather than in iCloud, our guide explains how to restore messages on your iPhone from it.
Get past Activation Lock after the erase
Activation Lock comes with Find My. Apple says it turns on automatically when Find My is turned on, and it stays on after a remote erase. During setup, Apple says to enter the Apple Account and password you used on the iPhone, or its passcode. Since the passcode is what you forgot, the account is what gets you through.
iOS says so in Settings too. On our iPhone, the line under the Find My iPhone switch reads "This device cannot be erased and reactivated without your password", which is Activation Lock in one line.
If the iPhone belongs to a business or school, Apple says to contact its IT department. If you can't get past the screen and have proof of purchase, Apple lets you start an Activation Lock support request. If you plan to sell or give the iPhone away once you are back in, follow our steps to erase an iPhone before selling it, so it is no longer linked to your account.
If you forgot your Apple Account password too
The on-device reset and Activation Lock both ask for your Apple Account password, so sort it out first. Apple's easiest way is a trusted device, such as an iPad or Mac already signed in to your account with its own passcode. On an iPhone or iPad, open Settings, tap your name, then Sign-In & Security and Change Password.
With no trusted device, Apple suggests borrowing one and using the Apple Support app, or resetting the password at iforgot.apple.com. If that fails, account recovery can take several days, and Apple says contacting Apple Support can't shorten that wait. Our guide shows how to recover your Apple Account password on each kind of device.
Once you are back in
Pick a new passcode you will remember when setup asks for one. To change it later, Apple's path on an iPhone with Face ID is Settings, then Face ID & Passcode, then Change Passcode, and Passcode Options offers a four-digit code, a custom numeric code or an alphanumeric one.
Then make sure Back Up This iPhone is on under iCloud Backup. Apple says automatic backups run when the iPhone is connected to power and Wi-Fi with its screen locked, so a phone left charging on Wi-Fi with its screen locked backs itself up. When you change the passcode again, Apple's previous-passcode window gives you up to 72 hours on iOS 17 or later, unless it is expired early.
How we tested this guide
We tested this on an iPhone 17 Pro with iOS 26.6, going through the iCloud Backup and Find My iPhone pages in Settings.
Frequently Asked Questions
Can I unlock my iPhone without losing data?
Only with the previous passcode, if you changed the code in the last 72 hours on iOS 17 or later and the old code was not expired early. Every other Apple route erases the iPhone, and you get your data back from a backup or iCloud.
Why don't I see Forgot Passcode on my iPhone?
Apple says it appears only on iOS 17 or later when the iPhone has a cellular or Wi-Fi connection, is signed in to an Apple Account and has Find My turned on. On iOS 15.2 and 16 the button reads Erase iPhone. If any of those is missing, erase it with Find My from another device if Find My was on, or use a computer in recovery mode.
Why does Enter Previous Passcode not work?
The old code works only for 72 hours after a change, and Apple's Expire Previous Passcode Now setting can end that window early. After that, the reset is the documented route.
Will I lose my photos and messages without a backup?
Not if iCloud Photos and Messages in iCloud were already syncing them, because they come back when you sign in. Anything stored only on the iPhone and never backed up is lost when it is erased.
Can Find My erase an iPhone that is offline?
Yes. Apple says the request waits as Erase Pending and the erase starts the next time the iPhone connects to Wi-Fi or cellular, with Activation Lock still on afterwards.
Why does my erased iPhone say iPhone Locked to Owner?
That is Activation Lock, which stays on after a remote erase. Sign in with the Apple Account that was on the iPhone, or use Apple's Activation Lock support request if you have proof of purchase.