shadow1ng/fscan · error
parser_no_valid_hosts
Error message
parser_no_valid_hosts
What it means
After collecting hosts from the file and host argument and applying exclusions, ParseIP requires at least one remaining target. If the deduplicated, sorted list is empty it returns 'parser_no_valid_hosts'. This fires when no hosts were supplied, every line failed to parse (invalid lines are skipped), or exclusions removed everything.
Source
Thrown at common/parsers/parsers.go:84
if strings.TrimSpace(exclude) == "" {
continue
}
hasExclude = true
if err := matcher.add(exclude); err != nil {
return nil, fmt.Errorf(i18n.GetText("parser_parse_exclude_failed")+": %w", err)
}
}
if hasExclude {
hosts = excludeFromList(hosts, matcher)
}
}
// 去重和排序
hosts = removeDuplicateStrings(hosts)
sort.Strings(hosts)
if len(hosts) == 0 {
return nil, fmt.Errorf("%s", i18n.GetText("parser_no_valid_hosts"))
}
return hosts, nil
}
// parseHostString 解析主机字符串
func parseHostString(host string) ([]string, error) {
var hosts []string
for _, h := range strings.Split(host, ",") {
h = strings.TrimSpace(h)
if h == "" {
continue
}
switch {
case h == "192":
cidrHosts, err := parseIPCIDR("192.168.0.0/16")View on GitHub (pinned to 95cc12e753)
Solutions
- Provide a non-empty host argument (e.g. -h 192.168.1.0/24) or a valid hosts file
- Check the hosts file for content and that entries are in a supported format
- Reduce or correct the nohosts list so it doesn't exclude every target
- Log/inspect skipped file lines — parseHostString errors are silently ignored
Example fix
// before
ParseIP("", "") // nothing to scan
// after
ParseIP("192.168.1.0/24", "") Defensive patterns
Strategy: validation
Validate before calling
if host == "" && filename == "" {
return errors.New("no targets: provide -h or -hf")
}
if filename != "" {
if data, _ := os.ReadFile(filename); len(strings.TrimSpace(string(data))) == 0 {
return errors.New("hosts file is empty")
}
} Try / catch
hosts, err := parsers.ParseIP(host, file, nohosts...)
if err != nil {
if strings.Contains(err.Error(), "parser_no_valid_hosts") {
log.Fatalf("no scannable targets remained (check -h/-hf and exclusions)")
}
return err
} Prevention
- Always supply at least one target source
- Keep exclusion patterns narrower than the target set
- Check hosts-file lines parse; invalid lines are skipped silently
When it happens
Trigger: ParseIP("", "") with no file; a hosts file containing only unparseable lines; or targets fully consumed by the nohosts list (e.g. ParseIP("192.168.1.0/24","","192.168.1.0/24")).
Common situations: Forgetting the -h argument, pointing -hf at an empty or comment-only file, or an exclusion pattern that overlaps all targets.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- result cannot be nil
- result cannot be nil
- output file not specified
- invalid output format: %s
- parser_cidr_failed: %w
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/86fe292c4c3e2736.
Report an issue: GitHub.