
Updated February 2020: Updated for macOS Catalina.
#How to edit hosts file mac os x how to
Enter your Administrative password when prompted (that's the password used by the main user to unlock their Mac). This video is how to open and edit Hosts files for Mac OS X Lion.Open 'Terminal'Type 'Sudo Nano /Private/etc/hosts' Without quotes.Type your password and cli.Click Replace when asked whether you want to replace the file.If you don't have the folder open in finder anymore, follow steps one through five to reopen it. Drag this same Hosts file from your desktop back into the same folder.# localhost is used to configure the loopback interface Paste the following into the same file: # Open the Hosts file from your desktop.Drag the Hosts file from the Finder window onto your desktop.Enter /private/etc/hosts into the search field.Make sure Finder is selected on your Mac.When you're ready to undo your changes and restore where your Mac's Hosts file routes to, you can do so by replacing the current host file with a new set of terms.

You can also use the Hosts file to block or work around spyware and ad networks by "zeroing out" their IP addresses - putting in 0.0.0.0 then the name of the domain you'd like to block. Easy for novices, but nano, vim, emacs, etc are better. You can save and edit the file as usual from TextEdit this way in OS X. You will need administrative privileges to edit the file, which you can do manually or by appending the new entry directly from the command line. Type your admin password, hit return, then TextEdit launches as root with the hosts file on the Mac. On Mac OS X, your hosts file is located at: /private/etc/hosts. Before the system's online and accessible to anyone using DNS, you can use the Host file instead: Enter the machine's IP address and when you use that domain name, your Mac will go to that device instead. Correct, you can edit Hosts file in OS X with TextEdit by entering: sudo open -a TextEdit /etc/hosts. The first is by using TextEdit since the hosts file is.

Let's say you're testing a development server you're about to deploy, and you'd like to use its domain name instead of the machine's specific IP address. There are two primary ways to edit the hosts file in Mac OS X. Here you have two common solutions that might be very useful on Edit hosts file on Mac OS X or OS X Server. Note: Before making changes, please backup your host’s files or copy lines of text onto another text file. There are some practical reasons why you'd want to use the Hosts file instead of just letting DNS do its thing. However, to edit hosts files follow the below steps carefully. It's called the Hosts file, and it can be used to override the default DNS information. The Domain Name System and its associated cache is your Mac's standard way of knowing how to get to where it's going on the Internet, but there's another file that can be very useful. Your Mac builds up a hidden cache file to remember those details later on when you visit the same site again. The first time you type in a web address, your Mac pings a DNS server - typically one automatically configured for you by your Internet Service Provider - to find out the TCP/IP address of the server you're trying to connect to.
