How to Fix iTunes Error 21 (Corrupted Firmware File) When Restoring iPhone
What error 21 means
Error 21 appears in iTunes on Windows or Finder on a Mac while you're restoring or updating an iPhone. The message reads, "The iPhone could not be restored. An unknown error occurred (21)," and the phone drops into recovery mode with the computer-and-cable screen, waiting for a restore that will actually finish. Your data isn't gone and the phone isn't broken — the attempt just never passed verification.
Behind the "unknown error" label is a very specific meaning. Every iPhone restore runs on an IPSW firmware file — several gigabytes of system software that iTunes downloads from Apple. Before installing it, iTunes checks the file's cryptographic signature against Apple's servers to make sure it arrived intact and unmodified. Error 21 means that integrity check failed: the file on your computer doesn't match what Apple expects, whether because the download corrupted, something altered it, or the transfer to the phone broke it apart mid-restore.
That makes error 21 a computer-side and file-side problem, not an iPhone problem. The fixes below work in a deliberate order: first the physical connection, then the software, then the firmware file itself, and finally a clean DFU restore if nothing else sticks.
Common causes
- Corrupted or incomplete IPSW firmware download: even a small glitch in the file fails the signature check, and every retry with the same file fails the same way.
- Antivirus or firewall interference: security software quarantining or blocking the firmware file during download or verification.
- Outdated iTunes or macOS: old builds mishandle the firmware verification handshake with Apple's servers.
- Bad USB cable or port: dropped data mid-restore breaks the integrity check — cheap third-party cables are the classic culprit.
- Stale hosts-file entry: a leftover gs.apple.com redirect from downgrade attempts or firmware tools sends verification to the wrong server.
How to fix error 21 — step by step
Work through these in order. Most error 21 cases end at step 1 or step 4 — the cable and the firmware file cover the overwhelming majority — so don't skip ahead to the DFU restore until you've tried the simple fixes first.
- Use an Apple-certified cable and a different USB port. Error 21's firmware check fails when the data stream between the computer and the iPhone gets interrupted mid-restore, and worn or non-certified third-party cables are the most common cause. Unplug the cable from any hub or dock and connect it directly to the computer — on a desktop PC, use a rear USB port, which delivers power more reliably than the front ones. Try a second cable if you have one, then restart the restore from scratch rather than resuming.
- Update iTunes or macOS and restart. An outdated iTunes build or an old macOS version can mishandle the firmware verification handshake and throw error 21 even when the file itself is fine. In classic iTunes on Windows, click Help at the top of the window and choose Check for Updates. If you use the Apple Music and Apple Devices apps on Windows, update them from the Microsoft Store under Library. On a Mac, Finder handles the restore, so keep macOS current through System Settings, General, Software Update. Restart the computer fully, then try the restore again.
- Temporarily disable security software. Antivirus programs and firewalls sometimes quarantine or block the firmware file while iTunes downloads or verifies it, which corrupts the process and triggers error 21. On Windows, open Windows Security, go to Virus and threat protection, and pause real-time protection; also make sure the firewall is not blocking iTunes. Run the restore with the protection off, then turn everything back on immediately afterward.
- Delete the firmware file and download it again. If the IPSW file picked up even a small corruption during its download, every restore attempt using that file will fail with error 21. On a Mac, open Finder, hold the Option key, click Go, Library, then go to iTunes, iPhone Software Updates, and delete the .ipsw file inside. On Windows, press Windows key + R, type %AppData%\Apple Computer\iTunes\iPhone Software Updates, and delete the .ipsw file there. Disconnect the iPhone, restart the computer, reconnect, and let iTunes or Finder download the firmware fresh before restoring.
- Check the hosts file for gs.apple.com entries. A redirect in the hosts file can push the firmware verification toward a server that is not Apple's, which makes the signature check fail and surfaces as error 21 — especially if you ever tried to downgrade iOS or used third-party firmware tools. On Windows, run Notepad as an administrator and open C:\Windows\System32\drivers\etc\hosts; on a Mac, edit /etc/hosts from Terminal. Remove any line mentioning gs.apple.com, or put a # at the start of the line to comment it out. Save, restart the computer, and retry the restore.
- Enter DFU mode for a clean restore. If error 21 keeps returning, do a Device Firmware Update restore, which reloads both the software and the firmware from scratch with a freshly downloaded file. Connect the iPhone to the computer, then: press and quickly release Volume Up, press and quickly release Volume Down, hold the Side button for 10 seconds, then — still holding Side — hold Volume Down for 5 seconds, release Side, and keep holding Volume Down for about 10 more seconds. The screen stays completely black in DFU mode. iTunes or Finder will detect a device in recovery and offer a restore; accept it. DFU mode erases the iPhone, so restore your data from an iCloud or computer backup when it finishes.
Did this fix it? Quick checklist
- Apple-certified cable connected directly to the computer, no hub or dock
- iTunes, the Apple Devices app, or macOS updated — and the computer restarted
- Security software paused only during the restore attempt, then re-enabled
- Downloaded IPSW deleted and re-downloaded fresh on a stable connection
- The restore completes without error 21 (or the DFU restore succeeds)
If error 21 survives a new cable, updated software, disabled security tools, a fresh IPSW, and a DFU restore, the problem may be deeper — a failing iPhone USB controller or NAND storage. At that point, note that you've already cleared error 21's known software causes and book an appointment at an Apple Store or authorized service provider; telling them you've ruled out the firmware side saves a diagnostic round.
Frequently asked questions
What does iTunes error 21 mean?
Error 21 means iTunes or Finder could not verify the iPhone's firmware file (the .ipsw) against Apple's signature during a restore or update, so the process stopped with the message 'The iPhone could not be restored. An unknown error occurred (21).' It is a firmware-verification failure, not a hardware failure — the computer-side file or connection is the problem in the large majority of cases.
Why is my iPhone firmware file corrupted?
The IPSW usually corrupts during download — a dropped connection, an antivirus interfering mid-download, or a flaky USB transfer during the restore. iTunes verifies the file's cryptographic signature before installing it, and it rejects any file that fails the check, even if the corruption is tiny. Deleting the downloaded file and fetching it again on a stable connection fixes it in most cases.
Can a bad USB cable really cause error 21?
Yes. The restore pushes gigabytes of firmware data over USB while iTunes continuously verifies what arrived. A worn or non-certified cable can drop bits mid-transfer, and the failed integrity check surfaces as error 21. Apple-certified cables connected directly to the computer — no hubs or docks — eliminate this variable before you touch anything else.
Does error 21 mean my iPhone is jailbroken or bricked?
No. Error 21 appears on completely stock iPhones too, and it does not mean the phone is permanently damaged. It means one restore attempt failed verification. The phone is sitting in recovery mode waiting for a successful restore — work through the cable, software, and firmware-file steps above, and it almost always comes back to life on the next clean attempt.
Is error 21 the same as error 3194?
They are related but different. Both block restores around Apple's server verification, but 3194 specifically means Apple's server refused the firmware — usually a hosts-file redirect or an attempt to install an iOS version Apple no longer signs. Error 21 means the firmware file itself failed its integrity check on the way in. If you see 21, start with the cable and the downloaded IPSW file; if you see 3194, look at the hosts file first.