How to Edit Your Mac Hosts File in macOS High Sierra

If you are wondering why Hosts File is still in demand when the problem is already resolved by DNS, then you must know that at some point of time your Mac or machine may fail to reach a DNS server. The Hosts file has the ability to configure those demanding IP address mappings and also provide precession of local override before DNS does. Thus it is important to learn how to edit Mac hosts file in macOS High Sierra.

While setting up your Mac to add a new server and connect it to the internet, the process can be backed by spyware and adware networks but there is this covert Hosts File in your Mac which will assist you to get rid of the headache. One thing you must know that DNS is automatic while Hosts File is manual and that’s what gives you more control over it. Before we move on into editing the Hosts file of macOS High Sierra manually, let’s get a clean idea of those two files or programs.

Domain Name System

The DNS, acronym of Domain Name System, is the phonebook of internet. In technical terms, it memorizes the domain names and translates them to Internet Protocol i.e., IP addresses. What happens in the background is that it gathers all the information of domain name servers spread throughout the internet and stack them at Central Registry. Then the Host companies and Internet Service providers cooperate with the Central Registry on a regular schedule to acquire refurbished DNS information.

When you are typing a web address, e.g., “www.indabaa.com”, your browser will ping the internet service provider and they will receive the DNS linked to the domain name which translates it into the TCP/IP address. This is how it establishes connection with the website. Meanwhile, your Mac has been simultaneously creating a cache file in case you might have to re-visit the site again.

Hosts file

The Hosts file is very similar to DNS. Both of them know where everything is traversing on the internet. It is very useful because you can manually override the pre-existing information of DNS with this operating system file. This file consists of lines of text of IP addresses and many host names.

If you are having trouble with spyware and ad networks while browsing, use the Hosts file to block them by zeroing out their IP addresses. Put “0.0.0.0” and then the name of the domain you want to block.

How to Edit Mac Hosts File in macOS High Sierra

The very first step of this process is to know where the Hosts file lie in your Mac. To work in the finest possible way, use the Terminal application. It lies in the “Utilities” folder of your Mac. Gather the IP address of the device you will like to send your Mac’s data to or the domain names you want to block. You can also search in the “Spotlight” for Terminal or find it in the Finder from dock. Follow the steps below:

Step #1: Open “Finder” window.

Open Finder Window

Step #2: Click on “Applications” from the Sidebar.

Click on Applications

Step #3: Double-click on “Utilities”.

Click on Utilities

Step #4: Double-click on “Terminal”. You will be asked to enter your admin Password and enter a command in order to open the Nano text editor.

Click on Terminal

Type “sudo nano /etc/hosts” and hit “Return”.

Again enter your Admin Password which you use for login and hit “Enter”.

Terminal Window on Mac

Now you are inside the Nano Text Editor. In this window, at the bottom you will see many alphabets with the function they are assigned to.

If you want to add any device or a website name, move the cursor with the arrow keys to settle it beside the text and start typing.

In case, you want to map an IP address on your local network and assign it to a domain, type the IP address and hit “Tab” and then write the domain name.

If you want your Mac to keep away from certain sites, use the IP address “127.0.0.1”. This way, you can also make sure that it won’t go to its planned site. Even if your router is set to any different IP address, 127.0.0.1 will traverse your Mac back to its default Hosts file settings.

After you are finished configuring, press and hold “Control” and “O” keys together to save the file and then press “Control” and “X” key at the same time to exit.

Type “sudo killall -HUP mDNSResponder” and hit “Enter” at the command line. This command is for removing your Mac’s DNS cache information so that it doesn’t get puzzled with the changes made to the Hosts File.

The manual functionality of the Hosts File is the main advantage over the automated DNS program. Just remember, because you have modified the Hosts file, the changes might have to be set to its default state in order to ensure your Mac will perform well.

Also Check:  How to Reset and Flush DNS Cache in macOS Sierra

Liked this information on how to edit Mac Hosts File in macOS High Sierra? Share your feedback with us on FacebookTwitter and Google Plus.

LEAVE A REPLY

Please enter your comment!
Please enter your name here