Skip to content

/errors/nmap/failed-to-resolve

nmap: Failed to resolve "example.local".

The commands on this page have not been executed by our verification runner yet.updated
tool
Nmap
exit code
0
versions
Nmap 7.x
os
linux, macos, windows

Failed to resolve "example.local". means nmap could not turn one of your targets into an IP address with the system resolver, so it skipped that target. It is a DNS (or typing) problem, not a scan result. Check the spelling, pass only a host name or address (no :port suffix, no URL parts), or scan the IP address directly. If no other target is left, nmap continues and ends with WARNING: No targets were specified, so 0 hosts scanned.

Where the message comes from

The text comes from libnetutil/NetBlock.cc in the nmap source, which resolves host-name targets: Failed to resolve "%s". is printed for a name with no addresses. The same code prints related lines; the two address-family warnings are each followed by the Failed to resolve line:

MessageMeaning
Failed to resolve "NAME".No address found for NAME
Warning: Hostname NAME resolves, but not to any IPv4 address. Try scanning with -6Only AAAA records exist: add -6
Warning: Hostname NAME resolves, but not to any IPv6 address. Try scanning without -6Only A records exist: drop -6
Bare '-': did you put a space between '--'?A stray - was read as a target

nmap does not stop at an unresolvable target: it scans the remaining ones and, at the end, the exit status is 0. Scripts should parse the output (for example -oX or -oG) rather than rely on the exit code.

Targets nmap accepts

bash
nmap -p 80,443 scanme.nmap.org         # a host name
nmap -p 22 192.0.2.10                  # an IPv4 address
nmap -6 -p 443 2001:db8::10            # an IPv6 address (needs -6)
nmap -sn 192.0.2.0/24                  # a CIDR range
nmap -iL targets.txt                   # one target per line from a file

scanme.nmap.org is the host the Nmap project provides for test scans; only scan systems you are authorised to test. The other addresses are documentation examples to replace with your own.

Check the name

bash
nslookup example.local
dig +short example.local A
dig +short example.local AAAA

.local names are usually resolved by multicast DNS (Avahi, Bonjour), which the resolver nmap uses may not query. Use the IP address in that case.

Sources