Skip to content
Latchkey

host: Usage, Options & Common CI Errors

host does quick, one-line DNS lookups - the simplest of the trio.

host is the most concise DNS tool: one line of output, sensible exit codes. That makes it the best of dig/nslookup/host for a scriptable CI resolution check - when it is installed.

What it does

host performs DNS lookups, printing a short human-readable line per record. Unlike nslookup, it returns a meaningful non-zero exit code on failure, which makes it convenient as a resolution gate in scripts.

Common usage

Terminal
host example.com
host -t MX example.com
host -t TXT example.com
host -a example.com                              # all records, verbose
host example.com 8.8.8.8                          # use a specific server

Options

FlagWhat it does
-t <type>Query a specific record type
-aAll records (equivalent to -t ANY, verbose)
-vVerbose output
<name> <server>Resolve using a specific server
<ip>Reverse (PTR) lookup

Common errors in CI

"Host example.com not found: 3(NXDOMAIN)" prints and host exits non-zero - unlike nslookup, that makes host usable directly as a gate (host name >/dev/null && echo ok). "connection timed out; no servers could be reached" means the resolver is unreachable (network/resolv.conf issue) - try specifying a server. host ships in bind-utils/bind9-host/dnsutils and is missing on many slim and Alpine images; install it or fall back to getent hosts.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →