owasp-amass/amass · error
invalid IP address in resolvers file: %s
Error message
invalid IP address in resolvers file: %s
What it means
After reading the resolvers file, each non-empty line must parse as an IP address via net.ParseIP. This error is returned when a line is not a valid IPv4/IPv6 literal, aborting the whole load. The offending line is included in the message.
Source
Thrown at config/resolvers.go:243
if err != nil {
return nil, fmt.Errorf("failed to open resolvers file: %w", err)
}
// Split the file data by newlines to get the IP addresses.
lines := strings.Split(string(data), "\n")
var resolvers []string
for _, line := range lines {
line = strings.TrimSpace(line)
// Skip empty lines.
if line == "" {
continue
}
// Check if each line in the file is a valid IP address.
ip := net.ParseIP(line)
if ip == nil {
return nil, fmt.Errorf("invalid IP address in resolvers file: %s", line)
}
resolvers = append(resolvers, line)
}
return resolvers, nil
}
View on GitHub (pinned to 79299dce87)
Solutions
- Open the resolvers file and fix or remove the line reported in the error
- Replace hostnames with literal IP addresses (net.ParseIP does not resolve names)
- Remove CIDR ranges and comments; only bare IPv4/IPv6 literals are accepted
- Strip trailing whitespace/CR (Windows line endings) from lines if IPs look correct
Example fix
// before (resolvers.txt) dns.google # public dns // after (resolvers.txt) 8.8.8.8 1.1.1.1
Defensive patterns
Strategy: validation
Validate before calling
for _, l := range lines(strings.TrimSpace) { if l != "" && net.ParseIP(l) == nil { return fmt.Errorf("bad resolver line: %q", l) } } Type guard
func isIPLine(s string) bool { return net.ParseIP(strings.TrimSpace(s)) != nil } Prevention
- Only put literal IPv4/IPv6 addresses in the file, one per line
- No comments, CIDR, or hostnames in resolvers files
- Sanitize Windows CRLF line endings
- Validate the file with a lint script before use
When it happens
Trigger: A line in the resolvers file contains a hostname, a comment, CIDR notation (e.g. 10.0.0.0/8), trailing whitespace artifacts, or any malformed text that net.ParseIP rejects.
Common situations: Users paste DNS server hostnames (8.8.8.8 works, dns.google does not) or include # comment lines, empty lines with stray characters, or IPv6 entries with zone indices.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- %s is not a valid IP address or range
- %s is not a valid IP
- brute forcing cannot be performed without DNS resolution
- active enumeration cannot be performed without DNS resolutio
- resolvers section is not a list
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/6707c29e84de83d0.
Report an issue: GitHub.