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.
##
127.0.0.1 localhost
255.255.255.255 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:

208.117.236.69 youtube.com
208.117.236.69 www.youtube.com

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

 

Goodbye.