How To Edit HOSTS File on Mac

Generally choosing Terminal connection on Mac for this operation. We will look via Terminal now.

First step we should open Terminal console from search or Application / Utilities

Type this command :

sudo nano /etc/hosts

And you will sample record and notification at content of hosts file.

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
## localhost broadcasthost
::1 localhost
fe80::1%lo0 localhost


I recommend don’t change this record. Only add to last line which record you need.

Sample record for last line:

When you have finish add record, press ctrl + x, press for save to Y  and then press Enter for save.

That’s it. You have add successfully.

If you need to flush dns records type it:

dscacheutil -flushcache