To edit the hosts file in Mac, open the Terminal. It is in Applications -> Utilities -> Terminal.
$ sudo nano /private/etc/hosts
Add the IP addresses and hostname(s) – use a space to separate aliases or multiple hostnames
192.168.1.5 myapp.local www.myapp.local
Press Ctrl-O and press Enter to save. Press Ctrl-X to exit nano.
To flush DNS cache, on terminal issue the following command…
$ dscacheutil -flushcache
Way to go…