How to: Fix iTunes error 1013 (when upgrading or restoring)

[ 72 ] Tuesday, 8 February 2011 |

Recovery ModePhoto credit: hirotomo (Flickr)

Having recently updated my iPhone 4 to iOS 4.2.1 I can report that it wasn’t without pain. For a period of time I found myself stuck on the recovery screen because iTunes couldn’t verify my iPhone with Apple’s servers. For reasons known only to Apple, when you restore your iDevice, iTunes will “prepare” your iPhone for restore i.e. place it in a unusable state before then verifying with Apple that it’s cool to upgrade before then proceeding to load new firmware. [C'mon, seriously Apple? - do that before you put my device into recovery mode please!] Each and every time I attempted to restore my iPhone I ended up with “The iPhone could not be restored. An unknown error occurred (1013)“. This was down to a pesky entry in my hostfile that needed eradicating. If you’re in the same boat then here’s the fix I found when doing a little Googling:

Mac OS X

1. On your Mac, open your Applications folder.

2. Navigate to the Utilities folder.

3. Open Terminal.

4. Type “sudo nano /etc/hosts” (without quotes) and press enter.

5. Enter your password

6. Use the down arrow key to find the gs.apple.com entries. Once the cursor is in front, make sure you comment out the line(s) by entering # in front of the text.

7. Save the file by pressing CONTROL+O.

8. Exit the nano editor by pressing CONTROL+X.

9. Restore your iDevice.

Windows

1. Press Start, then Programs, then Accessories

2. Launch Notepad or WordPad

3. Click Open from File menu.

4. Browse to Windows/System32/drivers/etc

5. In “files of type:” select all documents

6. Open “hosts

7. Delete all line that have gs.apple.com or similar

8. Hit Save

9. Restore your device

Sources: @Gustasn0w for Windows steps & Tech-Exclusive for Mac steps

UPDATE: Important notes if you are getting the error when installing an older firmware

There are some occasions where you want to install an older firmware and do so using a tool like TinyUmbrella to give access to those SHSH blogs you’ve got saved (since Apple doesn’t sign old firmware). If you get error 1013 when updating with TinyUmbrella running, do the following:

– let the iPhone boot to the iTunes recovery screen
– stop your TSS server from running in TinyUmbrella
– click “Exit Recovery” in TinyUmbrella
– iPhone will now boot as normal and you can jailbreak as you would before

This basically happens because the baseband is being preserved.

Tags: , , , , , , , , , , , ,

Category: Apple, How To, iPad, iPhone

About the Author ()

Architect, tech meddler, former Jailbreaker, married and father of 2. Sporadic Apple blogger who doesn't have the time to follow a tog career.
  • Pingback: Vote on this article at blogengage.com

  • Pingback: Tweets that mention How to: Fix iTunes error 1013 (when upgrading or restoring) | the last place on the net -- Topsy.com

  • Delmercado2000

    no sirve tu solucion man

  • http://twitter.com/Simply_Dovine Nikki D. Amaker

    Thank you! You are an iPhone life saver!

  • http://lastplaceonthe.net Rob

    You’re most welcome!

  • http://twitter.com/Tyler_UT_SEO Tyler

    Thanks!!!!! Worked perfect for me.

  • Basilnolan

    Oh my god, you saved me… Can’t say anymore… you are really my savior. Can’t express how much gratitude

  • http://lastplaceonthe.net Rob

    No problem. Glad it worked for you.

  • Phaethons Ride

    My “hosts” file did not have any line that had “gs.apple.com” in it. Anyone know what to do now? I still have the 1013 error.

  • http://lastplaceonthe.net Rob

    There are other apple servers remove all of them.

  • tizhang

    I’m getting this error too and my hosts file literally has nothing in it except for text that’s commented out. This is what’s in it:
    # Copyright (c) 1993-2009 Microsoft Corp.## This is a sample HOSTS file used by Microsoft TCP/IP for Windows.## This file contains the mappings of IP addresses to host names. Each# entry should be kept on an individual line. The IP address should# be placed in the first column followed by the corresponding host name.# The IP address and the host name should be separated by at least one# space.## Additionally, comments (such as these) may be inserted on individual# lines or following the machine name denoted by a ‘#’ symbol.## For example:##      102.54.94.97     rhino.acme.com          # source server#       38.25.63.10     x.acme.com              # x client host# localhost name resolution is handled within DNS itself.# 127.0.0.1       localhost# ::1             localhost

    So unless this is the wrong file and the real hosts file is hidden, I’m not sure what to do.

  • http://lastplaceonthe.net Rob

    Which firmware are you loading please and to what device?

    Have you tried a different USB port and direct to the computer?

    Are you connecting via work Internet or straight to Internet at home?

  • Bobby Hernandez

    When I go to Word Pad and attempt to remove the apple servers and then go to save it, it tells me that my access was denied??? :-(

  • http://lastplaceonthe.net Rob

    You have to edit the file as an administrator. If you aren’t logged in as admin do so.

  • Xerxes

    YOU are the MAN!! You saved me hours of frustration and pain.

  • Jugrajmann007

    Still not working :/

  • kobeuno

    thanks a lot man,its working…

  • http://lastplaceonthe.net Rob

    Which stage do you get to and what have you tried from the above detail please?

  • http://lastplaceonthe.net Rob

    No problem – happy to have been able to help!

  • Guesswho1247

    Access denied yet im the admin?? What is goin on?

  • http://lastplaceonthe.net Rob

    PC or Mac?

  • Emermandocdoc

    i did all that stuff but its still saying error 1013 on mine hat should i do?

  • http://lastplaceonthe.net Rob

    PC or Mac?

    Chances are the change you made hasn’t taken effect. Have you rebooted after updating your hostfile. (iPhone hard reboot too – press and hold both the power and home buttons until the Apple logo appears).

  • Bwilder1991

    it keeps saying i cant save the file because im not an administrator, but im on the only user on my computer  and i am the administrator

  • http://www.facebook.com/profile.php?id=1836637774 Amir Ghanem

    i did what you said but it wont work i dont know why :(
    i hope anyone help me please 0000……

  • http://lastplaceonthe.net Rob

    Reboot and do it in safe mode instead. You know how?

  • http://lastplaceonthe.net Rob

    You’ve done all the stuff in the update section too?

  • U_jav16

    in my hosts file there are not such commands like gs.apple , they are already erased and i m still getting error 1013…what should i do??

  • http://lastplaceonthe.net Rob

    Reboot both phone and computer. Try again. Failing that use a friends PC. Could be your machine causing the issue.

  • Grldchia

    im doing the restore now… hope it works…

  • http://lastplaceonthe.net Rob

    Good luck!

  • Me

    useless article.  Not only is it a cut and paste of EVERYONE elses, it doesn’t help the people that don’t care about Apple’s stupidity and autocracy.

  • http://lastplaceonthe.net Rob

    I wondered how long it’d be before we got a troll – welcome to you!

    If you can show me where this is a cut and paste of anyone else’s work then I’d love to see it. Particularly when you look at dates and times – for sure, I’ve seen my work copied elsewhere numerous time. At the end of the day, Apple support articles are there for people to interpret and use and people like me write clearer and helpful information (for free) to help others. Just because there hasn’t been a spoon feed article for you that solves your problem doesn’t give you the right to spout rubbish. Given your attitude my personal recommendation is you sell anything Apple you own and go and buy another manufacturer’s brand. Plenty of people have solved their issues by following the guidance here in.

    Remember your IP is logged and remember the Internet isn’t anonymous – libel laws do exist.

  • LM17

    I want to restore my iPhone on my new Macbook Air, but I get the error 1013 when i’m trying.. I’m on Lion. Have tried deleting the apple-lines in hosts, but that did not help me. :( What am I doing wrong? 

  • http://lastplaceonthe.net Rob

    I’ve had a few occasions where, despite removing the lines, they’ve persisted.
    Try a reboot, open the host file and check they’ve gone.

    If they remain then delete them again, reboot and try once more.

  • Elissarife

    I do not have any gs.apple lines in my host folder and my iphone has never been jailbroken before, what should I do?

  • http://lastplaceonthe.net Rob

    Reboot the iPhone the computer and connect the iPhone straight to the computer using your USB lead. Not via any hubs or extensions.

  • khawaldeh

    i have do all of your suggestions…and dont work….. i have to rejailbreak my iphon to let it work please help me…..still have problem 1013 when i restore the firmwork ……it start the restore and in the middle of it stop and give me this message

  • http://lastplaceonthe.net Rob

    Which firmware are you restoring to?

    Couple of options for you:

    1. Open TinyUmbrella and use kick out of recovery.
    2. Get greenpois0n and run that to jailbreak it at that point since that will take it out of recovery and jailbreak older firnwares.
    Can’t say more without more detail since you’ve only given limited info.
    Good luck.

  • PKha2

    THANKS A MAN! U save ME!! Finally my iphone can restore sucessfully.If unable hit save, just save hosts notepad in yr document. u need to delete hosts in Windows/System32/drivers/etc.Then drag hosts from yr document to Windows/System32/drivers/etc.
    Finally u can open iTune and click restore. That is all.

  • Darius9222

    hey, i click exit recovery from tinyumbrella but it doesn’t exit. I am trying to downgrade from 4.3.5. to 4.3.3.

  • Andy

    hey i got the iphone 4 and i’m trying to upgrade from ios 4.3.2 to ios 4.3.3 but i keep getting error 1013. The solution for which i hear is to remove the gs.apple line from the host file but if i do that i just get a lot more errors and i can’t get it to come out of restore mode now because it failed halfway through the restore and tinyumbrella does not recognise the iphone 4 Please help you really seem to know everything about this

  • http://lastplaceonthe.net Rob

    Hi there,

    Generally when the iPhone gets to the error it’s done the firmware upgrade but it won’t progress any further and sticks in a recovery reboot loop.
    Are you on Windows or a Mac? At the end of the day what you are looking to achieve is to kick the iPhone out of recovery and hope that it will boot after that. For you, I suspect the gs.apple lines are a misnomer.
    You say that TinyUmbrella doesn’t recognise the iPhone. I assume the phone isn’t listed and the Exit Recovery button isn’t there. There are a few other tools for kicking devices out of recovery. I haven’t used many of them since TU usually works for me. I have never tried RecBoot but it may be worth giving it a go: http://www.ijailbreak.com/applications/recboot-kick-your-idevices-into-and-out-of-recovery-mode/
    Good luck and please report back to let us know how you get on.

    Cheers!

  • Tygerlock

    I am having this same problem; I’ve gone to my hosts file and all I have is:

    ##127.0.0.1 localhost255.255.255.255 broadcasthost::1             localhost fe80::1%lo0 localhost

    Is there any other way to fix my problem? 

  • Kyle

    thank you so much. i was starting to think i could not get rid of this error code

  • http://lastplaceonthe.net Rob

    Which firmware are you trying to restore? Is it the latest or an older one.

  • http://lastplaceonthe.net Rob

    No probs. Glad you are sorted.

  • Shailendra Gupta

    Thanks for help in get rid from the 1013 error

  • guest

    Having trouble with step 5 i have browsed to Windows/System32/drivers/etc through open on notepad but there is nothing there. but if i browse to Windows/System32/drivers/etc without notepad hosts is there

  • http://lastplaceonthe.net Rob

    That’s because Notepad doesn’t recognise it as a supported file format.
    Browse to the location not in notepad, right click it and then select Open With > Notepad.

  • Roslee7

    i am a mac user and i using terminal…they asking me the password and what is the password? in terminal, i couldnt edit it

  • http://lastplaceonthe.net Rob

    Whatever your password is for your Mac’s user account.

  • kevin

    i have same problem and im trying to update to 4.3.5 firmware

  • kevin

    also i have tried using a different pc, i used my friends and he was also jailbroken and he updated fine, but i cannot restore and update what is going on! =S
    Please help!!!

  • Richard

    Every time I restored iTunes gave error 1013, and the options in TinyUmbrella “Exit Restore Mode” and “Fix Restore Mode” would not work.  So eventually I reinstalled iOS4.1 since the Cydia server had my SHSH for it.  (being a downgrade from the iOS4.3.3 and iOS4.2.1 restored unsuccessfully, DFU mode is required)  iTunes still fails with the error 1013, but with iOS4.1 the button EXIT RESTORE MODE in the application TinyUmbrella *DOES* work (with iOS4.3.3 and iOS4.2.1 the exit restore mode button fails).  My phone is now back to where I started but is happily running again unjailbroken at the moment.

  • Maira56

    I’m trying to do exactly what you’ve said using my Windows, but everytime i try and save i get a message saying @abouthere:disqus ‘you don’t have permission to save in this location. Contact the administrator to obtain permission.” What am I supposed to do now??

    Please help….
     

  • Maira56

    no idea why it says ‘rob’ half way through the post =S

  • http://lastplaceonthe.net Rob

    Are you an administrator of the computer? You might be logged in with standard user rights only, or you’ve another user logged in (don’t use the switch user functionality).

  • Santos_nd87

    i cant restore to ios 5?
    help plz

  • Santos_nd87

    itunes is not restoring my iphone 4, i have 4.3.3 and
    saved shsh what can do? i wanna get ios 5 hel plz

  • Spongebok87

    thank you!!!

  • Trac

    Hi! I opened up Windows/System32/drivers/etc/hosts but can’t find anything remotely similar to “gs.apple.com”. I rebooted both my computer and iphone yet… nada. Any suggestions? My phone had been previously unlocked/jailbroken on a PC

  • noonoo

    when you get “access is denied” error message, even when you are logged in as administrator, try this:
    when you hover to notepad, right click and select “run as administrator”.  it works! :)

  • Toegyi08

    your expression is very nice

  • http://usb3gvn.com USB 3G

    This imformation is a great help. Try to keep your imformation. I and other people need to understand about it. Thank you !

  • Joder_

    did not work for me

  • Silesteraq

    it works! THANKS MEN! you really help me a lot! i fucked up when im finished installing SPITE then after rebooting, it all goes to apple logo for so many hours, then i’ve tried to reboot it using redsnow, but then it stuck up again at apple logo, and pineapple logo.. ive tried it so many times, so my only hope is to restore it, but then error comes from the itunes.. so ive searched a lot of thing just to fix the error, and then i saw your post.. thx men!! it really help me! BTW sorry for my english, im not that good ^_^ thanks again!

  • Sri Swaminathan Vanarasi

    while doin this i donno know wat happened and my iphone has to recovery mode , now when io try to restore im getting 3194 error… please help me out

  • http://twitter.com/Geethareddy12 Geetha Reddy

    when i connect it to itunes its showing a message invalid sim

    please help me out

  • Rana101

    i tried it its not working and it was saved properly too.

  • disqus_HOswpXx8WC

    i tried doing the windows step but once i got to the windows/system32/drivers/etc part it said the file name is not valid…with the yellow triangle and exclamation mark in it.I tried several times with both word pad and note pad.HELLLLLLLP FRUSTRATION SUCKS

  • http://www.facebook.com/martha.paredes.940 Martha Reyes

    When I try to type in my password which 0000 it does not type anything at all

7ads6x98y