Hosts File For A Mac

Posted on

The hosts file performs a name to IP address mapping and was used on early computer networks for name resolution before DNS was developed. The hosts file is still present on computer systems (windows,Linux, MAC), tablets (e.g. Android) etc and can be very useful for testing purposes. The hosts file is a simple text file that can be edited with. NOTE: The following guide is intended to assist if you are using a Mac OS X computer. If you are using Windows, please refer to our guide on how to Modify Your Hosts File Using Windows. The hosts file is used by your computer to lookup/resolve domain names to an IP address. This file can be used to. The hosts file in Windows, Mac, or Linux maps hostnames to IP addresses. For example, an intranet, like a corporate office that has servers for users to access, or it could be domain names for servers on the internet. Editing your hosts file can be useful if you are running tests on your network.

Where is the host file

When you encounter an iTunes error like 3194, network failures, or connectivity issues, it is recommended to edit the hosts file. If you have updated the file many times, the original version is gone. Of course, you would have ideally created a backup copy of the original, but in the event that you didn’t, here’s how to reset the hosts file to default in macOS and Windows.

What is the Hosts File?

Hosts File For A Mac

The simplest explanation is that it is a text file used by your computer to map a connection between an IP address and domain names. It can be edited to test certain network aspects or to troubleshoot connectivity issues. Of course, you should keep a backup of it before editing. But in case you do not, you can still recover the original version as explained below.

How to Reset the Hosts File Back to Default in macOS

On a Mac, the hosts file mostly contains nothing more than a couple of lines of active code. The rest of the stuff is just commented out (description of the hosts file itself).

To reset, we are going to open the hosts file in a text editor, replace the entire file with the default text and save it. That’s it.

  1. From the Finder, navigate to GoGo to Folder.
  2. Type this in the Go to Folder window: /private/etc/hosts
  3. From the finder window, click and drag the hosts file to the desktop. (We are doing this because we can’t open directly and edit it.)
  4. Double-click the hosts file (on the desktop), and it will open in TextEdit (or any default text editor on your Mac).
  5. Erase everything in it by pressing Command + A to select all and then press the delete key.
  6. Copy the following piece of text and paste it into the hosts file.
  7. Save this file by clicking on the red close button. Or, click on File from the top menu bar and then select Save.
  8. Open the Go to Folder window and open /private/etc/hosts again.
  9. Step #9. Drag the hosts file from the desktop back to the /private/etc/ folder.
  10. You will be asked about the existing hosts file. Choose Replace and authenticate with the admin password when asked for it.
  11. Restart the Mac to get things rolling again.

How to Restore the Hosts File Back to Default in Windows

  1. Open Notepad on your PC
  2. Go to this page and copy the text of the hosts file for your OS version. Different hosts file contents exist for different Windows versions (although they vary slightly)
  3. Once you’ve pasted the text into Notepad, save the file as “hosts” – include the quotes. (this is because you don’t want to save the file as a .txt file). Save it on the desktop so that you can easily access it in the next few steps
  4. Now, open this location: %WinDir%System32DriversEtc You can do this by opening Run and pasting the location here
  5. Once the folder opens, drag and drop the hosts file from the desktop into the folder. You will be prompted to replace the file and then prompted for the admin password

With this huge update to the hosts file, you might want to restart your computer.

The hosts file is usually used just to map web addresses to specific IP addresses and to block websites (by re-directing/mapping them to invalid/incorrect IPs).

Signing off…

This is how you can reset hosts file to default. Once you change it to default, it may resolve some connectivity problems that you have with your computer.

You may like to check:

I have been an Apple user for over seven years now. At iGeeksBlog, I love creating how-tos and troubleshooting guides that help people do more with their iPhone, iPad, Mac, AirPods, and Apple Watch. In my free time, I like to watch stand up comedy videos, tech documentaries, news debates, and political speeches.

Hosts File For A Mac
  • https://www.igeeksblog.com/author/ankur/
    How to Turn ON or OFF Facebook Nearby Friends on iPhone
  • https://www.igeeksblog.com/author/ankur/
  • https://www.igeeksblog.com/author/ankur/
    How to Turn off Unread Mail Count in Mail App on iPhone or iPad
  • https://www.igeeksblog.com/author/ankur/
    How to Get Final Cut Pro X and Logic Pro X Free for 90 Days

Active computer users are probably already familiar with the Hosts file that contains network information. Through this file you can block access from your computer to a particular website, or make other changes to the access of your computer to a certain IP address. Despite the fact that Mac Os is a system that is pretty much closed from user interference, it has a file named Hosts that can be edited. At the same time, editing here is not at all more difficult than on Windows, and within the framework of this article we will tell you how to do this.

How to open and edit hosts via “terminal”

The easiest way to access Host file editing is to use a command line, which in Mac OS is called “Terminal”. You can run “Terminal” utility through the Finder, it is located in the list of standard programs of the operating system, or you can just use a search and type its name.

File

“Terminal” is running and now you need tostart editing the Host file. To do so you will need to enter and execute the following command:

After activating this command, you will also need to enter the administrator’s password for the computer, because intervention in Hosts file is quite serious, and if this file is edited incorrectly, you may experience problems accessing certain websites on the Internet.

After entering the right password, you will be able to see the Host file contents that can be edited by a user. When editing the file through “Terminal” your mouse will not work, so you will have to move between the lines of this file only with the help of your keyboard. Enter the changes you would like to make in the Hosts file. To save all changes in this file, you will need to press Ctrl + X on your keyboard. Next you are going to see a message asking you to confirm whether you want to change Hosts or no, confirm the action with “Y” button.

How to open and edit hosts via finder

The second way to access Hosts and edit the file involves using the standard Finder. This way, you can open the Hosts file and edit it in any text editor, so this option may be preferable in a number of cases.

To open Hosts through the Finder you need to right-click on the lower menu on the Finder and select “Go to Folder”.

Hosts File For A Mac Download

Then there will open a window and in this window you need to enter a path to the folder you want to go to. Enter the following address:

And click “Go.”

There will open a system folder in which the Hosts file is located. To start editing it, you need to right-click on it and select the editor that you would prefer to work with (you can use the standard TextEdit).

In the window that opens, you can edit the Hosts file just like any other file in a text editor. But the Hosts system file is protected from editing. After you try to make changes to it, you will see a message with suggestion to create a duplicated file. Click “Duplicate”. After that the second file will form on the basis of the first one.

Next, you will need to make all necessary changes to the new created file and save it in a convenient place, for example, on the desktop. When saving, select the .txt resolution (same resolution that the original Hosts file has). Now your new file is saved and you will need to just replace the old file in the system folder. To do this, drag the new file to the folder where the old Hosts is located and click “Replace” when the corresponding message appears. As a result of these actions, the old Hosts file will be deleted, and the new one will be used by the system instead.

How to apply hosts file changes

Some changes that are made in the Hosts file are not perceived by the system at once and, accordingly, do not work. For the changes to take effect, you need to update the DNS cache. This can be done using the terminal with the command:

Hosts File Mac Address

After executing this command, the Hosts file will be read by the system again, and all the changes that were made to it will be reflected on the computer’s operation.