How can I debug a DNS record?

As a frontend developer, you don't really want to worry too much about DNS. However, it can be frustrating when DNS records block you from doing your work. Read on to learn some basic troubleshooting steps for your DNS records.

Apex Domain and A Records

An apex domain is your root domain without any subdomains, like vercel.com. Notice that there is no www prefix. If you'd like to have your apex domain hosted on Vercel, make sure that you have a single A Record with the value of 76.76.21.21 (Vercel's Anycast IP Address).

If you have multiple A Records set for your domain, conflicts can arise because different regions will resolve to different addresses. To confirm that the record is set correctly, you can run the following command in your terminal:

$ dig vercel.com +short

The dig command for revealing vercel.com's A Record (replace with your own domain).

If your A Record is configured correctly, you will have a single IP address appear (76.76.21.21). If you see nothing or more than one IP, double check your DNS record to make sure it is set correctly.

Subdomains and CNAME Records

When you want to set up a subdomain like api.vercel.com, you need to configure a CNAME Record. The Name field of your CNAME record should be set to the name of your subdomain without including the apex domain. Continuing with our example, the Name field for api.vercel.com would be api - not api.vercel.com. The Value field should be set to cname.vercel-dns.com.

You can see if your DNS record was set correctly by running the following command in your terminal:

$ dig cname api.vercel.com +short

The dig command for revealing api.vercel.com's CNAME record (replace with your own subdomain).

Mail and MX Records

When you want to use a custom domain for sending and recieiving email, you need to set MX Records with values for your mail provider. If you are using GSuite from Google for example, you can find the list of the required MX records here.

Note:

You can use MX presets provided by the Vercel DNS editor to save some time.

The Name field should be blank or set to the at (@) symbol, but the Value and Priority fields should be set as instructed by your mail provider.

You can see which MX Records are set for your domain by running the following command in your terminal:

$ dig mx vercel.com +short

The dig command for revealing vercel.com's MX records (replace with your own domain).

Global Propagation

It's important to keep in mind that DNS is a distributed system coordinated by many parties all across the world. A certain region may resolve a DNS record with one value and another region may resolve it as another. DNS changes can take some some time to propagate everywhere consistently.

If you want to get a clear view of how the world sees your domain, you can use a tool like WhatsMyDNS? to get the full picture for each of your DNS records.

Updated October 30th 2020