How to Modify/Edit Hosts File on Mac, MacBook In macOS Big Sur/Catalina, Mojave, High Sierra, EI Capitan, Yosemite

Last Updated on Nov 10, 2020

Hosts file has an essential role in website configuration & Blocking port. So you can make your own rules about your website hosted on the Local mac running on macOS Mojave, High Sierra, EI Capitan, Yosemite or OS X Server. Point IP address to the desired website URL So you can override DNS temporary by making changes in hosts file located on Mac System. For Edit hosts file on Mac, we need little technical knowledge, and then you can do with ease. However, to edit hosts files follow the below steps carefully.

we are happy to help you, submit this Form, if your solution is not covered in this article.

Note: Before making changes, please take a backup of your host’s files or copy lines of text on to another text file. Here you have two common solutions that might be very useful on Edit hosts file on Mac OS X or OS X Server.

Steps on How to Edit the Hosts File on Macbook, Mac with Latest MacOS

Apple didn’t make any changes on the path of the hosts file location and Command syntax for the older OS X version. Same steps you can try on any OS X version.

I recommend using the Command Line method to open the host file on your Mac. Due to Security Reason, Simple folder method on Your Mac or MacBook Doesn’t Allow to edit hosts file directly like a simple file. You should change on a duplicate Hosts file first. So,

First Easy Way: Command for Open Hosts File on Mac and Edit File Normally

Terminal on Mac

Terminal on Mac

  1. Open terminal on Mac, To Open on Mac, Type Terminal on Spotlight Search [Command + Space]. or Directly open from Launchpad.
    • If it asks then Enter the Mac Admin password and press return.
  2. Type in terminal: sudo nano /private/etc/hosts and hit the Enter to open Hosts file on Mac screen.

    Open Host file on Mac using Terminal and Direct Edit

    Open Host file on Mac using Terminal and Direct Edit

  3. Use Arrow key on your keyboard to move a cursor and start Editing, Here I added one line. Once you edited.

    Move Cursor in Host file to Edit on Host file on Mac

    Move Cursor in Host file to Edit on Host file on Mac

  4. Press Control + X from keyboard to Save. Now in the Next Window, Your will be asked to enter Y for yes and N for No.

    Save and Exit from host file on Mac

    Save and Exit from host file on Mac

  5. Press Y to move the earlier screen of host file.

    Press Yes to Agree host file

    Press Yes to Agree to host file

  6. Now, Press the Return [Enter] from mac Keyboard to close the Hosts file and Move to Terminal window.
    Hit Return button to Exit host file window

    Hit Return button to Exit host file window

    Now, You are on Terminal Screen. Now, You can verify or check the Hosts file by Re-Open with a terminal command. Hope you help this way very easily.

    Move back to terminal on Mac

    Move back to the terminal on Mac

  7. That’s it.

Second Way: Open & Edit Hosts File on Mac Without Terminal Command

You can make changes by shortcut keys give on-screen.

Step 1: Open a Finder Window on your Mac.

Edit hosts file on Mac from finder

Step 2: From Top menu, go to the GO > GO TO FOLDER.

Step 3: Move to Hosts files location type in the text box: /private/etc/hosts and Click on Go.

Go to hosts file on Go to menu

Step 4: double click on file named hosts, File will be open in the text editor.

Hosts file Location on Mac OS X

Step 5: Inside the hosts file you can edit after broadcasthost.

How to Save Hosts File on Mac Using Keyboard Shortcuts?

Type or edit on hosts file

Here I redirected twitter account to another website IP for my Mac only. Not work on other Mac. Before Edit file you have to make the new copy of host file, and changes will be saved to a new copy. Then you have to replace that new file with the original file (/private/etc/hosts) manually. Due to privacy reasons, you can’t make changes directly on the original hosts file.

To Exit or Save,

Control + X to Exit and Press Y key to Save in hosts file. and Tap on Return or Enter Button. [Play Below video to Learn on my Mac’s screen]

New copy of host file on Mac


That’s it. Nothing else. Want more help on Edit hosts to file on macOS Catalina, Mojave, EI Capitan, Yosemite or OS X Server. Share with me on the comment.

Useful: Best Dictation software for Mac

Jaysukh Patel is the founder of howtoisolve. Also self Professional Developer, Techno lover mainly for iPhone, iPad, iPod Touch and iOS, Jaysukh is one of responsible person in his family. Contact On: [email protected] [OR] [email protected]

We will be happy to hear your thoughts

Leave a reply