How to edit hosts file using Terminal on a Mac
If you are getting errors in iTunes while trying to restore a jailbroken iPad, iPhone or iPod touch you will need to edit you hosts file. There are a few ways to do this on a Mac but the simplest way is using Terminal.
- To get stated open the Terminal app. You can search for Terminal using Spotlight, or by go to Applications -> Utilities -> Terminal.
- After Terminal is open paste or type;
sudo nano /private/etc/hosts
- Then press Enter and enter your password when prompted.
- Find the address “188.8.131.52 gs.apple.com” (or something to that effect.) This is what you will need to delete, it’s normally at the end of the hosts file.
- You can navigate the file in Terminal using the arrow keys. After the address is deleted, press control-o to save the file then press enter.
- You can press control-x to exit the editor.
Your hosts file should now be edited. You can verify that it was edited by opening the file and seeing that the line was removed. You can open it in Terminal as in step 2 or you can open Finder, click “Go”, then “Go to Folder”, type /etc/ and press return. You can then find and open the hosts file.
Now you should be able to restore your device in iTunes.