71°F

Aaron Parecki

  • Articles
  • Notes
  • Photos
  • /etc/hosts - The hosts file

    April 19, 2006

    The other day I decided to set up my iBook so that I can do web development on it.

    While setting up my new server, I was moving a domain name to the new server, but didn't want to actually change the DNS for the domain until I knew Apache was configured properly. I needed some way to test Apache's virtual host configuration without actually making the DNS change. Turns out, since OS X is based on UNIX, you can add dns entries to your computer manually.

    Edit the file /etc/hosts, and include the name and IP address for the host you want to add. For example:

    ##
    # 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
    123.123.123.123        domainname.com
    

    You'll need to do this with root privileges, since it is a system file. You'll have to do something like

    sudo vi /etc/hosts
    

    In OS X 10.5 it is no longer necessary to reload the hosts file. It will happen automatically.

    sudo niload -v -m hosts . < /etc/hosts
    

    After that, you should be all set! Your computer will resolve dommainname.com to 123.123.123.123 without contacting any DNS servers.

    Note, this is not an OSX-specific feature. Windows also has a hosts file. It is usually located at:

    c:\windows\system32\drivers\etc\hosts
    

    To get Windows to recognize the changes, you need to flush the DNS.

    ipconfig /flushdns
    

    You can also read about the hosts file on Wikipedia.

    Wed, Apr 19, 2006 3:55pm -07:00
Posted in /articles

Hi, I'm Aaron Parecki, Director of Identity Standards at Okta, and co-founder of IndieWebCamp. I maintain oauth.net, write and consult about OAuth, and participate in the OAuth Working Group at the IETF. I also help people learn about video production and livestreaming. (detailed bio)

I've been tracking my location since 2008 and I wrote 100 songs in 100 days. I've spoken at conferences around the world about owning your data, OAuth, quantified self, and explained why R is a vowel. Read more.

  • Director of Identity Standards at Okta
  • IndieWebCamp Founder
  • OAuth WG Editor
  • OpenID Board Member

  • 🎥 YouTube Tutorials and Reviews
  • 🏠 We're building a triplex!
  • ⭐️ Life Stack
  • ⚙️ Home Automation
  • All
  • Articles
  • Bookmarks
  • Notes
  • Photos
  • Replies
  • Reviews
  • Trips
  • Videos
  • Contact
© 1999-2025 by Aaron Parecki. Powered by p3k. This site supports Webmention.
Except where otherwise noted, text content on this site is licensed under a Creative Commons Attribution 3.0 License.
IndieWebCamp Microformats Webmention W3C HTML5 Creative Commons
WeChat ID
aaronpk_tv