DEV Community

Scott Robertson
Scott Robertson

Posted on • Originally published at on

Route all .dev URL's to

If you're like me, you always forget to edit the /etc/hosts file when you want to view a local site.

To get around this, you can use the following script to route all your .dev urls to (or any other IP). So you could go to "" and that would load from

brew install dnsmasq
mkdir -pv $(brew --prefix)/etc/
echo 'address=/.dev/' > $(brew --prefix)/etc/dnsmasq.conf
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver" > /etc/resolver/dev'

Enter fullscreen mode Exit fullscreen mode

If you wish to use another IP, only change the first, otherwise it will look for a name server on the host.

Top comments (0)