In an article I wrote last March (When an iOS update fails), I detailed my frustrating experience with a 1013 error in iTunes that occurred during an attempt to update my iPhone to iOS 4.3. The error left my iPhone in recovery mode. I was forced to do a complete restore of the device to get it working again. A second attempt at the update led to the same failure. It was only after I tracked down the cause to a modification of the /etc/hosts file that I was able to get the update to succeed.
I assumed that was the end of the matter. As it turns out, I assumed incorrectly. In my prior diagnosis, I had been wrong in more ways than one. I had been wrong about the exact cause of the problem and wrong about what I needed to do to fix it. The unraveling of this mystery led to two surprises—one unwelcome and the other welcome.
Last week, when I attempted to update my iPhone to iOS 4.3.2, the dreaded 1013 (and recovery mode) error reappeared. Nothing I tried would get the iPhone to exit recovery mode. My only hope seemed to be yet another time-consuming full restore.
But the nagging larger question was: why was this still happening? Last time, I determined that the cause was a redirect line (220.127.116.11 gs.apple.com) added to the /etc/hosts file. I blamed myself for its presence, noting that I had added the line during some research I was doing and had probably forgotten to remove it when I was done with the task.
I was wrong. It turns out that I had remembered to delete the problematic line. What really happened was that a new copy of the line had been re-added to the hosts file, without my knowledge and behind my back, via the TinyUmbrella application.
TinyUmbrella is a Mac application that can store SHSH files associated with each iOS version for your iOS device. With these data preserved, TinyUmbrella can later restore your iOS device to an older version of the iOS (something that is otherwise impossible to do in Tunes with any recent iOS hardware). Most people will never need to do an iOS downgrade. Still (as I have written about previously), there are situations where it can come in handy. That’s why, as a matter of routine, I launch TinyUmbrella prior to doing an iOS upgrade, to make sure that I have all recent SHSH files stored. I did so prior to updating to iOS 4.3.2.
This TinyUmbrella launch was the precipitating cause of my 1013 error. For a downgrade to work, a redirect line must be added to the hosts file; the added line forces a connection to a Cydia server rather than Apple’s server. It turns out that, after launching and quitting TinyUmbrella, even if you perform no action at all, the application adds the redirect line to the hosts file. This in turn leads to the 1013 error when you next attempt to upgrade the iOS in iTunes. This was the unwelcome surprise.
Fortunately, you can avoid all of this (and still use TinyUmbrella). To do so, after launching TinyUmbrella, select the Advanced tab, uncheck the option that reads “Set Hosts to Cydia on Exit,” and click “Apply Changes.” TinyUmbrella will now comment out the redirect line, if present, in hosts when you quit the application. Regardless, I consider this very bad behavior for an application. The option should be off by default, not on. At the very least, the application should provide a warning before modifying a hosts file.
Finally, I returned to my iPhone, still stuck in recovery mode after my failed attempt at updating. TinyUmbrella partly redeemed itself here. This was the welcome surprise. I noticed that TinyUmbrella included a button labelled “Exit Recovery.” Hmmm. With my iPhone connected, I clicked the button and…yes!…my iPhone successfully rebooted. I powered down the iPhone and restarted once more—just to be sure all was working. It was. No restore was required. As a bonus, iTunes had apparently completed the update to iOS 4.3.2 before the 1013 error had popped up. My iPhone was now running iOS 4.3.2 with no further work needed.