Tonight I decided to update an iPhone 4 to iOS 4.3.1. I sync my phone regularly and have never encountered an update problem. That changed tonight as the 4.3.1 update failed about five times in a row with error code 1013.
Clicking “more info” on the error message led me to this page which mentioned a possible problem connecting to gs.apple.com. I fired up a browser and tried http://gs.apple.com and was greeted with an Apache server directory listing. I figured since I got a response (and not a connection error) the problem must have been elsewhere, so I tried other suggestions from the support article: updating OSX, updating iTunes, changing USB ports, and rebooting. After each one, no luck: still the 1013. I began to sweat.
I read the support article closer, and even visited a large thread on the support forums and decided to peek at the /etc/hosts file. Sure enough, there was an entry for gs.apple.com! Where’d that come from?
I used a real man’s editor and commented out the entry for gs.apple.com. The very next restore attempt succeeded on first try.
$ sudo vi /etc/hosts Password:
Enter your own password at the prompt and press return.
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost #22.214.171.124 gs.apple.com ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "/etc/hosts" 11L, 264C
The important part is adding the # at the beginning of the line with gs.apple.com.
Note: if you’ve gotten this far but need help with the editor in this example itself, leave a comment and I can walk you through it. It’s the “vi” editor and it’s not very straightforward if you’re not used to the command prompt scene… there are several good quickstarts available online as well.
Update 4/5/2011: a good tutorial on editing the hosts file in general can be found here.
Hope this helps someone,
Update 4/5/2011: Here are the detailed steps on how to edit the system hosts file. These are instructions for OSX Snow Leopard. (I think with Windows you can just edit the file in Notepad; the file is located at C:\Windows\System32\drivers\etc\hosts)
OSX Snow Leopard instructions
- Open the Terminal app.
Click on the spotlight icon (magnifying glass in the top right corner of your screen) and type “terminal”. You should see a black square looking icon; click it.
- Edit the Hosts file.
I believe you need to be using an account with administrative privileges.
- Once Terminal.app opens, click on it and you should be able to type at the blinking cursor.
- Type the following:
sudo vi /etc/hosts
- Press the enter (or return) key.
- The terminal will ask you for your password. Type it carefully, because for security reasons it won’t show on the screen.
- Note: if you mistype your password, you should see “Sorry, try again.” up to three times.
- If you correctly entered your password, the editor will show you the contents of the hosts file.
- You should see a few lines like the example above.
- Use the down arrow key to move the cursor to the line that has “gs.apple.com” in it.
Leave the cursor on the first character in the line.
- Important: press the I key once.
This puts the editor in “insert” characters mode so you can type inside the file. We’re not in Pages or Microsoft Word, and this editor is not very forgiving – so type carefully.
- At the beginning of the line that has “gs.apple.com”, type a single hash (also known as pound) character.
It’s above the 3, so press the shift and 3 keys at the same time. If a 3 shows up instead of #, press the delete key to correct.
- The line should change colors.
The # character tells the system to ignore this line in the file, which is what we want.
- Press the colon ( : ) key once. That’s the shift and semicolon ( ; ) keys at the same time.
- Press the x key once.
- Press enter.
The :x command tells the editor to save and exit.
- Close and restart iTunes
- Re-attempt the iOS update or restore.