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

  1. Open the resolvers file and fix or remove the line reported in the error
  2. Replace hostnames with literal IP addresses (net.ParseIP does not resolve names)
  3. Remove CIDR ranges and comments; only bare IPv4/IPv6 literals are accepted
  4. 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

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


AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/6707c29e84de83d0. Report an issue: GitHub.