Error in restoring iOS 5.1.1 on iPhone 4 using custom IPSW

I'm trying to restore iOS 5.1.1 on iPhone 4 GSM that currently has iOS 4.3.3 and is jailbroken.

I'm using "redsn0w" to get into pwned DFU mode and then trying to restore from iTunes using custom IPSW file stitched with the 5.1.1 shsh blobs (I have my shsh blobs saved locally).

It works until iTunes reaches the point Preparing iPhone for restore.

At this point my iPhone automatically exits the DFU mode and enters into restore mode, but iTunes stops restoring with the error iPhone could not be restored. An unknown error occurred (21).

I have checked the hosts file and have commented the line that redirects to the cydia server. (I have also checked it by uncommenting that line but it still didn't work)

Any idea what could be going wrong or is there anything I'm missing?


I'm able to restore iOS 5.1.1 on my phone using sn0wbreeze. I'm posting the details here in case someone else encounters the same problem.

Initially I used redsn0w to create a custom firmware file but it failed to restore (with errors mentioned in the question and others like error 14, etc.).

Then I used sn0wbreeze to create a custom firmware stitched with my shsh blobs and iTunes restored it without errors.

Here are the steps I followed:

  • Downloaded a firmware that i wanted to restore (5.1.1 in my case).
  • Added my shsh blobs for that firmware using iFaith mode in sn0wbreeze.
  • Created the custom IPSW in sn0wbreeze and stored it on my desktop.
  • Put the iPhone in pwned DFU mode. Use iREB or redsn0w to get into the pwned DFU mode.
  • Used the custom ipsw file to restore in iTunes.

I don't know if these things count, but during the process my antivirus was disabled and I had commented out any gs.apple.com lines in my hosts file.