How To Edit Hosts File on MacOS

By Ammarrauf01

How To Edit Hosts File on MacOS. In this article, you will read what is Hosts file used for and how method to edit host file on MacOS. Sometimes, there is a need to edit the host file on your system. Because your host file can be edited maliciously. So, you may want to control access to certain websites or control network traffic.

What Is Hosts File Used For?

Host File are the computer system files. It is an operating system file that maps hostnames and connections between an IP address and domain names before going to domain name servers. This file is an ASCII text file. It contains IP addresses separated by a space and then a domain name. Originally a file named HOSTS.

It resolves host names for decades before the DNS system was implemented, since way back in the ARPANET days. It varies very little between Windows, macOS, and Linux. The syntax is almost the same.

The typical syntax consists of three parts. The first part is the location to redirect the address to, the second part will be the address that you will want to redirect, and the third part is the comment.

(IP Address) (URL) #(Comment) ; for example

127.0.0.1 localhosts #loopback

How To Edit Hosts File on MacOS?

You can find the host file in the Terminal. You can use your favourite editor. Use any command-line editor like Nano text editor. It’s versatile and user-friendly. The host file on macOS is located in /etc/ folder.

To edit the host file:

1.To open Terminal, click the Launchpad icon in the Dock.
2.Type Terminal in the search field.
3.Then click Terminal.
4.In the Finder, open the /Go/Utilities.

How To Edit Hosts File on MacOS - pic1

4.Then, double-click Terminal.

How To Edit Hosts File on MacOS - pic2

5.You can find the hosts file in the /etc/hosts folder.
6.Use any command-line editor from the Terminal.
7.Enter the following command into the Terminal application.

How To Edit Hosts File on MacOS - pic3

8.Next, press your Enter/Return key.
9.You’ll then be asked to type in your administrator password

How To Edit Hosts File on MacOS - pic4

10.Type in your password and hit the Enter/Return key once again.
11.Now, you’ll be brought to the Nano text editor.

How To Edit Hosts File on MacOS - pic5

12.For example, you want to add a new domain.
13.Navigate to the bottom of the file.
14.Then, on a new line, you can add the IP address of the domain you want to add. For example, I’ve added “123.123.123.123” as our new domain.

How To Edit Hosts File on MacOS - pic6