OSX /etc/hosts timeouts

OSX: 5 second timeout for domains defined in /etc/hosts

This is mostly for my own reference, this document has been sitting in my drafts folder since … like two years ago.

First of all, OSX claims .local for Bonjour and will treat them differently, so use .dev or something instead.

To add a host called myapp.dev and point it to localhost, just do this:

sudo dscl localhost -create /Local/Default/Hosts/mydev.dev IPAddress

To see all the currently defined hosts and their IPs:

sudo dscl localhost -list /Local/Default/Hosts IPAddress

And to remove a host:

sudo dscl localhost -delete /Local/Default/Hosts/mydev.dev

if you declare both a IPv4 and IPv6 address in /etc/hosts for a .dev domain like so: myapp.dev
::1 myapp.dev

Then it should work correctly.


Tags// , , ,