Technology

Fixing Local DNS Issues with .dev TLD

Today, I was eager to try out the new Lighthouse web developer tool site launched by Google at https://web.dev. It appears to be a great resource to help web developers improve their site's performance, accessibility, and learn a few new best practices.

Anyway, this is not a review of the new Google offering. Instead, it's hopefully a short post to help out anyone else that ran into the same issues we did getting the new site to resolve.

Notice the .dev TLD? Yep, it's the same one many developers have used as their default for many years. If you're a developer (like us), you probably used mysite.dev or myclientsite.dev to view your development on your local machine. Let's not get into the discussion why .dev was never a good idea to be used in the first place. Anyway, it worked fine until a late-2017 Chromium update broke all that goodness.

Of course, if you're a developer, none of this is news. You've already switched over to using .test or .localhost or maybe even .yourmama. The surprising thing to me was https://web.dev was the first legit usage of the .dev domain we had run across. However, when we tried to visit the site, it didn't resolve properly. That's because our computers were still thinking .dev was just local to our environments.

Good news the fix was easy, but you might have forgotten about it since we all abandoned .dev a few years ago in local development.

The following assumes you're on a Mac.

First, make sure you have no legacy .dev domains listed in your hosts file

sudo nano /etc/hosts

Next, take a look at dnsmasq. You may have used this to configure your local DNS.

cat /usr/local/etc/dnsmasq.conf

Do you see anything like the following?

address=/.dev/127.0.0.1

If so, remove it and restart dnsmasq

sudo nano /usr/local/etc/dnsmasq.conf

sudo launchctl stop homebrew.mxcl.dnsmasq

sudo launchctl start homebrew.mxcl.dnsmasq

Finally, take a look at the following.

cd /etc/resolver

ls

Do you see a file called dev?

If so, delete it.

sudo rm dev

That worked for us. Now, legit .dev sites should render properly. Hopefully, you found it just as easy.