• Home
  • How to Edit Hosts File on Mac

How to Modify Hosts File on Mac?

The Mac Operating System mainly uses host files to connect host names with the IP addresses. With the help of the host files, you can also block access to certain malicious websites to your office colleagues or children at home. Carry out these below-mentioned steps how to modify hosts file on Mac.

How to Modify Hosts File on Mac

To modify the host files on your Mac, you have to follow the steps as given below.

  • Turn on your Mac computer.
  • Access the launcher (F4 key) on your Mac.
  • Type Terminal and press the Return button.
  • The Terminal window will open.
  • Now you have to access the host file using the following command:
  • sudo nano /private/etc/hosts
  • You will be asked to type the Mac administrator password, enter the password and press the Return button.

The example-

  • IP_Address domain.com
  • IP_Address www.domain.com
  • Now, for example, imagine you want to imitate the DNS for Facebook to your IP address.
  • Follow the command as given below.
  • (Your IP address) facebook.com
  • (Your IP address) www.facebook.com
  • Press the Return button on your keyboard.
  • Once you have edited the hosts file, press the keys Command + X on your keyboard.
  • Type Y to save changes and press the Return button.

Close the Terminal window.

There are times when the changes aren’t saved automatically. In this case, you can flush the DNS cache.

  • If you are using OS X Snow Leopard, type sudo dscacheutil –flushcache.
  • If you are using OS X Mavericks, Mountain Lion, Lion, type sudo discoveryutil mdnsflushcache.

If you need a remote assistance regarding how to modify hosts file on Mac. Click the call button available on the screen.

shares