The Original, unmodified hosts file in Mac OS X is easy to restore if need beThe Original, unmodified hosts file in Mac OS X is easy to restore if need be

The hosts file is included on every computer and used by Mac OS to map IP addresses to host names. Because users may choose to adjust, change, or otherwise edit the hosts file for a variety of reasons, it can be easily subjected to user error, leading to a variety of undesirable network problems ranging from inaccessible network locations, network failures, web sites blocked or otherwise unable to load, even to failed iOS updates and various iTunes errors like the frequently encountered 17 and 3194 errors because the Apple servers have been blocked.

Fortunately, restoring the original default /etc/hosts file back to normal is pretty easy, and the best way to get back the original untouched default file is to simply overwrite the existing damaged hosts file with a new clean version that is a copy of what comes default in Mac OS X. An example of that has been included below for convenience, but you can retrieve it from another Mac if need be as well. No additional entries or modifications are included in the version below, which is a direct replica from that found in OS X Mavericks, making it safe to return to if you accidentally messed up the important hosts document during a change or adjustment.

You’ll want to copy the text below and paste it into a plain text file, stored at the /etc/hosts path. If you’re not sure how to do that, you can follow these instructions to learn how to edit the file the proper way from the command line and simply overwrite it with the hosts block below, or use TextEdit and save over the messed up version, which is what we’ll walk through below.

The Default & Original /etc/hosts File in Mac OS X Looks Like This

Contained within the code block is the original hosts file and the four default entries. Just copy and paste this over an existing hosts file then save it as plain text to restore it.

##
##
# 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

Those familiar with the command line shouldn’t have a problem with this, but if you’re not quite sure what to do you can also complete the process from the TextEdit app as we’ll describe below:

Restore an Unmodified Original Hosts File to Mac OS X

TextEdit is the simple text editor bundled with every Mac, you’ll also need administrator access to complete this task since the hosts document is a system file in a restricted directory.

  1. Open TextEdit and paste the above code block into a new empty blank file
  2. Select All text and choose “Format > Make Plain Text” and click “OK
  3. Choose “File > Save As” and uncheck the box for “If no extension is provided use txt” – this is important, DO NOT INCLUDE A FILE EXTENSION
  4. Restore the default hosts file in Mac OS XRestore the default hosts file in Mac OS X

  5. Hit Command+Shift+G to bring up the “Go To Folder” window, now type in /etc/ and go
  6. Name the file ‘hosts’ and save, you’ll need to enter an administrator password to be able to write to this directory
  7. Restoring the original default hosts file to a MacRestoring the original default hosts file to a Mac

Now to confirm the hosts file saved properly, go to the Terminal app and type the following:

cat /etc/hosts

That command should report the file to look like this:

The Original, unmodified hosts file in Mac OS X is easy to restore if need beThe Original, unmodified hosts file in Mac OS X is easy to restore if need be

If it doesn’t look like the sample hosts file above, you did something wrong. The most common problems are usually not saving the file as plain text, accidentally adding the file extension, or naming it incorrectly, so double-check that. If you’re still having problems, you may not have overwritten the file properly.

You’ll probably want to flush DNS cache or just reboot the Mac for changes to take effect system-wide and have the hosts file restored.

This is really the easiest way to restore the hosts file if you have messed it up, if it has become overly cluttered with tons of entries, or somehow other rendered the hosts database completely unusable. You certainly don’t need to restore an entire Mac from a Time Machine backup or reinstall the OS to accomplish this.

Source

Follow Me:
Top Best Sellers!!