How to Edit the Hosts File on a Mac

Method 1 of 1:

Editing Using TextEdit

  1. How to Edit the Hosts File on a Mac Picture 1
    Open the Terminal app. You can use the Spotlight search functionality to do this.
  2. How to Edit the Hosts File on a Mac Picture 2
    Copy the /etc/hosts file to a local file to be able to edit it.
    1. Type the command: cp /etc/hosts hosts .
  3. How to Edit the Hosts File on a Mac Picture 3
    Edit the copy of the hosts file using TextEdit.
    1. Type the command: open /Applications/TextEdit.app hosts
  4. How to Edit the Hosts File on a Mac Picture 4
    Add your new hosts file entry as a single line at the bottom of the file. The format of the line is "1.2.3.4 www.mynewdomain.com", where 1.2.3.4 is the IP address and www.mynewdomain.com is the domain you want to point at the IP address.
  5. How to Edit the Hosts File on a Mac Picture 5
    Copy the file hosts over top of the system /etc/hosts file. Do this by typing: sudo cp hosts /etc/hosts.
    1. You will be prompted for your password at this point because you are overwriting the system /etc/hosts file. Note that on the command line, when you type a character into the password field, nothing at all will appear.
  6. How to Edit the Hosts File on a Mac Picture 6
    Test your new local domain name by typing the domain name into your web browser.
    1. Note: your new domain name will not work until you have a web server responding at the IP address you specify!
5 ★ | 2 Vote

May be interested

  • How to Use Parental Controls on a MacPhoto of How to Use Parental Controls on a Mac
    there's a lot on the internet that your kids should be protected from. fortunately, apple makes it easy to monitor and limit your child's web use. follow these simple steps, and you'll soon be able to breathe a bit easier about your...
  • How to Use the Touch Bar on a MacPhoto of How to Use the Touch Bar on a Mac
    this wikihow will teach how to use the oled touch bar on the 2016 and newer macbook pro laptops. find the system functions. the system functions on the touch bar will almost always be present on the right side, in a section referred to as...
  • How to Use Picture in Picture on a MacPhoto of How to Use Picture in Picture on a Mac
    in fall of 2016, apple will release its new operating system for mac called macos sierra. among the new features this operating system will introduce is picture-in-picture, which allows users to keep a video window on top of all of their...
  • How to Make an Invisible FolderPhoto of How to Make an Invisible Folder
    this wikihow teaches you how to create a hidden folder. you can create hidden folders on both windows and mac computers as well as on android smartphones and tablets. although you can't technically create a hidden folder on an iphone, a...
  • How to Play Games in Your Mac TerminalPhoto of How to Play Games in Your Mac Terminal
    the terminal is an application inside all macs. it might be intimidating at first, because it's not as intuitive as the usual user interface, but it offers a lot of neat features, and you can use it do a lot of things that you would...
  • How to Zip a File on a MacPhoto of How to Zip a File on a Mac
    if you have a lot of old documents and files taking up space on your computer, you can compress them into an archive to save space. mac os x allows you to compress files directly from the operating system. you can also download third-party...