chrisstump
2/7/18 at 9:45 am
Plain Text
dns, mac
Steps for Modifying a Virtual Host File on Mac OSX
Follow this step by step guide for modifying your virtual hosts file to override DNS settings for a given domain.
1.) Open up a terminal window and run the following command: sudo nano /private/etc/hosts 2.) You will need to enter your password 3.) Edit the entry/entries as needed by providing an IP address and domain, for example: 127.0.0.1 mysite.com 127.0.0.1 www.mysite.com 3.) Write your changes by pressing using ^O (control + O) 4.) Flush the local DNS cache by executing the following command: dscacheutil -flushcache 5.) Open a browswer and confirm that your local DNS entries are working as expected. In the example above, www.mysite.com would be directed to 127.0.0.1
Copy Snippet to Clipboard
Don't Have an Account?
Stop digging through old code examples. Get organized. Get Code Snipper.
Learn More
Start Free 14 Day Trial