Marketing Tools

MacOS: Need to Verify DNS Locally Using Hosts on OSX?

One of my clients relocated their website to a bulk hosting account. They updated their domain’s DNS settings for the A and CNAME records but were having difficulty determining whether the site was resolving with the new hosting account (new IP Address).

When troubleshooting DNS, keep in mind a few things: Understand how DNS works, understand how your domain registrar works, and understand how your host manages its domain entry.

How DNS Works

When you type a domain into a browser:

  1. The domain is looked up in an Internet name server to locate where the request should be sent to.
  2. In the case of a web domain request (http), a name server will return the IP address to your computer.
  3. Your computer then stores this locally, known as your DNS Cache.
  4. The request is sent to the host, which routes the request internally and presents your site.

How Your Domain Registrar Works

Note: Not every domain registrar actually manages your DNS. I have one client, for example, who registers their domains through Yahoo! Despite appearing to do so in their administration, Yahoo! is just a reseller for Tucows. As a result, when you change your DNS settings in Yahoo!, it can take hours before those changes are updated in the real domain registrar.

When your DNS settings get updated, they are propagated across an array of servers across the Internet. Most of the time, this takes a few seconds to happen. This is one reason why people will pay for managed DNS. Managed DNS companies typically have both redundancy and are incredibly fast… often faster than your domain registrar.

Once the Internet servers are updated, the next time your system makes the DNS request, the IP address where your site is hosted is returned. NOTE: Remember that I said the next time your system makes the request. If you previously requested that domain, the Internet could be up to date, but your local system may be resolving an old IP address based on your DNS Cache.

How Your Host DNS Works

The IP address returned and cached by your local system isn’t typically unique to a single website. A host may have dozens or even hundreds of websites hosted on a single IP Address (typically a server or virtual server). So, when your domain is requested from the IP Address, your host forwards your request to the specific folder location within the server and presents your page.

How to Troubleshoot DNS

Because there are three systems here, there are also three systems to troubleshoot! First, you’ll want to check your local system to see where the IP Address is pointing to in your system:

OSX Terminal Ping

This is done easily by opening a Terminal window and typing:

ping domain.com

Or you can do a specific name server lookup:

nslookup domain.com
Terminal nslookup

If you’ve updated the DNS settings in your domain registrar, then you’ll want to ensure your DNS cache is cleared, and you’ll want to make the request again. To clear your DNS cache in macOS:

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
sudo killall mDNSResponderHelper
sudo dscacheutil -flushcache
Terminal Flush DNS Cache

At this point, you can retry the ping or nslookup to see if the domain resolves to a new IP address.

The next step would be to see if the Internet’s DNS servers have been updated. Keep DNSstuff handy for this: you can get a full DNSreport through their platform that’s really good.

If you see the IP address properly displayed across the web and your site is still not showing up, you can bypass the Internet’s servers and tell your system just to send the request directly to the IP Address. You can accomplish this by updating your

hosts file and flushing your DNS. To do this, open Terminal and type:

sudo nano /etc/hosts
Terminal Sudo Nano Hosts

Enter your system password and press enter. That will bring up the file directly in Terminal for editing. Move your cursor using your arrows and add a new line with the IP address followed by the domain name.

Terminal Hosts Save File

Press control-o on your keyboard to save the file, then return to accept the filename. Exit the editor by pressing control-x, which will return you to the command line. Don’t forget to flush your cache. If the site doesn’t come up okay, it may be a problem local to your host, and you should contact them and let them know.

Last note: Remember to return your hosts file to its original version. You don’t want to leave an entry that you want to update automatically!

By following these steps, I was able to verify that my the DNS entries in the registrar were up to date, the DNS entries on the Internet were up to date, my Mac’s DNS cache was up to date, and the web host’s DNS was up to date… good to go!

Douglas Karr

Douglas Karr is CMO of OpenINSIGHTS and the founder of the Martech Zone. Douglas has helped dozens of successful MarTech startups, has assisted in the due diligence of over $5 bil in Martech acquisitions and investments, and continues to assist companies in implementing and automating their sales and marketing strategies. Douglas is an internationally recognized digital transformation and MarTech expert and speaker. Douglas is also a published author of a Dummie's guide and a business leadership book.

Related Articles

Back to top button
Close

Adblock Detected

Martech Zone is able to provide you this content at no cost because we monetize our site through ad revenue, affiliate links, and sponsorships. We would appreciate if you would remove your ad blocker as you view our site.