When using a custom domain with Vercel, you are able to manage DNS records for the domain if the domain is using Vercel's nameservers.

To manipulate the DNS records for your domain, you can use the Vercel CLI. We recommend that you take a look at our official documentation for a complete explanation of the commands and options available.

Adding DNS Records

You can created a new DNS record by using the command vc dns add [...args]. For example, to create an A record you would use the following command:

vercel dns add example.com api A 127.0.0.1

Adding an A record to a custom domain with a record value of 127.0.0.1.

Another example would be adding an MX record for the root domain:

vercel dns add example.com '@' MX mail.vercel.rocks 10

Adding an MX record to a custom domain with a record value of mail.vercel.rocks.

Verifying DNS Records

Once DNS records have been changed, you may wish to check that these have been set corretly. There are many third-party tools that do this, such as DNS Checker and DNS Map - these show the state of your DNS records in different regions of the world.

You can also use the terminal to check the DNS record for your domain, examples of doing this for the records above are found below:

dig A api.example.com +short

Verifying the A record set for a domain using the terminal.

dig MX example.com +short

Verifying the MX record set for a domain using the terminal.

DNS records, with the exception of nameservers, are usually very quick to update, but can take a few minutes in some cases.

Removing DNS Records

If you need to remove DNS records, you can do so once again by using Vercel CLI.

To remove a record, you first need to get the record ID from the list of records present, this can be done like so:

vercel dns ls

Listing the DNS records set for all domains under a Vercel account.

This command outputs a list of the records for all domains available under your Vercel account along with a record ID for each.

From this list, you can copy the record ID into the following command, replacing the one present in the example:

vercel dns rm rec_6e9513aa7ac15300127a77b6

Removing a DNS record using Vercel CLI.

Common Errors

When working with DNS records, it can be easy to make minor errors in the syntax, these can be difficult to debug. Below is a list of common errors made when adding DNS records and the steps required to resolve them.

Using the domain as part of the "name" argument:

vercel dns add example.com api.example.com A 127.0.0.1

Incorrectly adding an A record to a custom domain with a record value of 127.0.0.1.

To solve this problem, remove the record and it again without the domain as the "name" argument:

vercel dns add example.com api A 127.0.0.1

Correctly adding an A record to a custom domain with a record value of 127.0.0.1.

Missing the "@" reserved word when inserting records for the root domain:

vercel dns add example.com A 127.0.0.1

Incorrectly adding an A record to a custom domain with a record value of 127.0.0.1.

To solve this problem, remove the record and it again without the domain as the "name" argument:

vercel dns add example.com "@" A 127.0.0.1

Correctly adding an A record to a custom domain with a record value of 127.0.0.1.