Unlock an iPhone

The exact behavior of the iPhone depends on its configuration when one forgets the passcode. By default, there is not a passcode at all. However, Apple notes the following regarding forgotten passcodes: If you repeatedly enter the wrong passcode, your iPhone will be disabled for longer intervals before you can try again. After too many unsuccessful attempts, you won’t be able to try again until you connect it to the computer with which you last synced it.
Note: You can configure your device to erase itself after ten consecutive incorrect password attempts. This setting is off by default. It can be turned on by tapping Settings > General > Passcode Lock.
If you cannot remember the passcode, you will need to restore your device using the computer with which you last synced it. This allows you to reset your passcode and resync the data from the device (or restore from a backup). If you restore on a different computer that was never synced with the device, you will be able to unlock the device for use and remove the passcode, but your data will not be present.
Follow the instructions in this article to unlock your iPhone for use with different carriers.
Check if your carrier offers unlocking. Only your carrier can unlock your iPhone.
Contact your carrier and request an unlock.
You may need to meet certain requirements to qualify for unlocking. After your carrier submits the unlocking request, it may take up to seven days.
Once you receive confirmation from your carrier that your iPhone unlock has been processed, proceed to the next section.
If you have a SIM card from a carrier that is different from your current carrier, and you’ve received confirmation from your current carrier that your iPhone is unlocked, follow these steps:
Eject your SIM card and insert the new SIM card.
Complete the setup process.
If you do not currently have another SIM card you can use, follow these steps to complete the process:
Back up your iPhone.
Erase your iPhone.
Complete the setup assistant and restore your backup.
Additional Information
If you experience issues or receive the following error message displayed in iTunes or on your device, follow the steps below:
“The SIM card inserted in this iPhone does not appear to be supported. Only compatible SIM cards from a supported carrier may be used to activate iPhone. Please insert the SIM card that came with your iPhone or visit a supported carrier store.”
Restore your iPhone.
Contact your carrier to verify that the unlock was applied in your carrier’s system.
Alternative way
If you have forgotten the passcode on your iPhone, you will have to restore the device.
To restore your iPhone — which deletes all of your data (songs, photos, videos, apps, and so on) on the iPhone use the following directions. Be absolutely sure that you have backed up the content on your iPhone before restoring it.
Apple’s official instructions to restore an iPhone are:
1. Connect iPhone to your computer.
2. In iTunes, select iPhone in the Devices list, then click Summary at the top of the screen.
3. Click “Check for Update.” iTunes tells you if there’s a newer version of the iPhone software available.
4. Click Restore. Follow the onscreen instructions to complete the restore process. When restoring, it is recommended that you back up iPhone when prompted. When the iPhone software has been restored, you can either set it up as a new iPhone, or restore your music, videos, app data, and other content from a backup.
Please also note that Apple representatives can’t unlock an iPhone for you without restoring the iPhone, which will erase everything on it.