Mac OS X / Add hosts to your local hosts file

Easily test your new domains without changing DNS Entries

A local hosts file stores DNS-like entries which your computer checks before it asks your DNS-Server(s). You can use this file if you want to test a website real quick but don't want to change DNS-Entries or if you don't want to publish the website yet. (Note: I'm just adding this here so i don't forget how this works)

Local Hosts file on a mac is located here:

In the hidden folder /private/etc/hosts if you have hidden folder turned off you can navigate there by using Finder/Go/Go To Folder... Once you're in the folder /private/etc/ all you need to do is open the hosts file with an editor of your choice, i recommend BBedit or the free alternative Textwrangler. BBedit will tell you that the file is locked, just type in your password and add your entry in the format:

IP address [tab] domain name64.233.167.99 google.com

And done, now just flush your dns cache

By using this command:

dscacheutil -flushcache

Just type it in your Terminal and hit return. It will clear your local DNS cache and reread the hosts file.

Disclaimer: Still-Scripts claims no responsibility for any damage that may occur from the use of any information found here or found on links followed from this page. All items, logos and/or companies mentioned on this and other pages are trademarks, registered trademarks, logos, copyrights, or service marks of the respective companies.