Editing the hosts file on macOS
A hosts file is a file that maps domain names to IP addresses. This article explains how to edit the hosts file on a Mac.
A hosts file is a file that maps domain names to IP addresses. This article explains how to edit the hosts file on a Mac.
Follow the steps below to edit the hosts file on Mac:
-
Navigate to Applications, then the Utilities folder, and then click on the Terminal app to open the Terminal application. Alternatively, type
Terminal
in the Spotlight to open the Terminal application -
To open the hosts file for editing, copy either one of the command below and paste in the terminal window and press Enter:
-
Or on newer macOS versions:
sudo nano /private/etc/hosts
-
sudo nano /etc/hosts
-
-
Enter the password to edit the host file. (Note: The cursor will not move when the password is typed.)
-
Move the cursor to the bottom of the file and enter the server IP and domain name separated by space:
SERVER_IP_ADDRESS domain.com
Important
There must be a space between IP and domain name
-
Save the changes by pressing control-o on your keyboard then return to accept the filename. Exit the editor by pressing control-x.
Related Articles
Updated 3 days ago