How to check DNS records with host

Query A, MX, CNAME, TXT, and NS records for any domain using the host command on Linux and macOS.

Query any DNS record type — A, MX, CNAME, TXT, or NS — for a domain using the host command on Linux and macOS.

Prerequisites

  • Linux or macOS with the host command installed (included in the bind9-dnsutils package on Ubuntu/Debian and preinstalled on macOS)
  • Terminal access
  • The domain name you want to query

Step-by-Step: Check DNS Records with host

1. Query the A Record for a Domain with host

The host command resolves a domain's A record (IPv4 address) by default when called with a domain name and no additional flags:

host example.com

The host command returns the IPv4 address mapped to the domain:

example.com has address 93.184.216.34

2. Query a Specific DNS Record Type with host

The host command accepts a record type as the second argument to query MX, CNAME, TXT, NS, or AAAA records. Specify the record type using the -t flag:

host -t MX example.com

The host command returns all MX (Mail Exchange) records and their priority values:

example.com mail is handled by 10 mail.example.com.

Other record types follow the same pattern with the host -t flag:

host -t TXT example.com
host -t NS example.com
host -t CNAME www.example.com
host -t AAAA example.com

3. Query DNS Using a Specific Nameserver with host

The host command sends queries to the system's default DNS resolver unless a specific nameserver is provided as the last argument. Query Google Public DNS (8.8.8.8) or Cloudflare DNS (1.1.1.1) directly to bypass local DNS caching:

host example.com 8.8.8.8

The host command connects to the specified nameserver and returns the result from that resolver, not from the local cache.

How to Verify DNS Records Were Retrieved Successfully with host

The host command prints results directly to standard output. A successful query returns one or more lines with the record data. A failed query returns "Host not found" or "NXDOMAIN" status, which indicates the domain does not exist in DNS.

Confirm the result by comparing it against a second public DNS resolver:

host example.com 1.1.1.1

Matching results across two DNS resolvers confirm the record is propagated and correct.

Common Issues When Checking DNS Records with host

host returns "connection timed out; no servers could be reached"— The host command cannot reach the DNS resolver. The local network may be blocking UDP port 53, or the specified nameserver may be unreachable. See host: connection timed out; no servers could be reachedfor diagnosis steps.

host returns "NXDOMAIN"— The domain does not exist in DNS. Verify the domain name for typos. Check whether the domain registration has expired using a WHOIS lookup.

host returns outdated records— The local DNS resolver may serve cached results. Query a public DNS resolver directly with host example.com 8.8.8.8 to bypass the cache. For a more detailed analysis of DNS queries, the dig commandprovides additional diagnostic output including TTL values and query timing.