Skip to content
Latchkey

host: Quick DNS Lookups in CI

host performs a DNS lookup and prints the answer on one line, making it the fastest way to confirm a name resolves in CI.

For a quick "does this name resolve and to what" check, host is terser than dig. It is ideal in scripts that just need the address or a yes/no on resolution.

What it does

host queries DNS for a name and prints the resulting records in a short, human form. Given an IP it does the reverse lookup. You can request a specific record type or query a specific resolver as the trailing argument.

Common usage

Terminal
host db.internal
host -t A api.example.com
# query a specific resolver to bypass a broken default
host api.example.com 8.8.8.8
# reverse lookup
host 10.0.0.5

Options

FlagWhat it does
-t <type>Record type: A, AAAA, MX, CNAME, TXT, NS
-aEquivalent to -t ANY plus verbose output
-vVerbose, dig-like output
-4 / -6Use IPv4 or IPv6 transport to the resolver
<server>Trailing argument: query this resolver instead

In CI

Appending an explicit resolver (host name 8.8.8.8) is the fastest way to tell a broken local resolver apart from a genuinely missing record: if the public resolver answers but the default does not, the container resolv.conf or DNS service is the problem.

Common errors in CI

"Host <name> not found: 3(NXDOMAIN)" means the name does not exist in DNS. "connection timed out; no servers could be reached" means the configured resolver in /etc/resolv.conf is unreachable, common in containers with a misconfigured DNS. "host: command not found" on alpine means installing bind-tools.

Related guides

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