{"record":{"id":"e794584811d5a4f5","repo":"caddyserver/caddy","slug":"invalid-start-port-v","errorCode":null,"errorMessage":"invalid start port: %v","messagePattern":"invalid start port: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"listeners.go","lineNumber":355,"sourceCode":"\t}\n\tif IsFdNetwork(network) {\n\t\treturn NetworkAddress{\n\t\t\tNetwork: network,\n\t\t\tHost:    host,\n\t\t}, nil\n\t}\n\tvar start, end uint64\n\tif port == \"\" {\n\t\tstart = uint64(defaultPort)\n\t\tend = uint64(defaultPort)\n\t} else {\n\t\tbefore, after, found := strings.Cut(port, \"-\")\n\t\tif !found {\n\t\t\tafter = before\n\t\t}\n\t\tstart, err = strconv.ParseUint(before, 10, 16)\n\t\tif err != nil {\n\t\t\treturn NetworkAddress{}, fmt.Errorf(\"invalid start port: %v\", err)\n\t\t}\n\t\tend, err = strconv.ParseUint(after, 10, 16)\n\t\tif err != nil {\n\t\t\treturn NetworkAddress{}, fmt.Errorf(\"invalid end port: %v\", err)\n\t\t}\n\t\tif end < start {\n\t\t\treturn NetworkAddress{}, fmt.Errorf(\"end port must not be less than start port\")\n\t\t}\n\t\tif (end - start) > maxPortSpan {\n\t\t\treturn NetworkAddress{}, fmt.Errorf(\"port range exceeds %d ports\", maxPortSpan)\n\t\t}\n\t}\n\treturn NetworkAddress{\n\t\tNetwork:   network,\n\t\tHost:      host,\n\t\tStartPort: uint(start),\n\t\tEndPort:   uint(end),\n\t}, nil","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/listeners.go#L337-L373","documentation":"In ParseNetworkAddress, the port component (before the '-' in a range like 8080-8090, or the single port) must parse as an unsigned 16-bit integer. This error wraps the strconv failure for the start port: non-numeric text, a value > 65535, or a negative sign.","triggerScenarios":"Addresses like ':http' (service names are NOT resolved), ':808O' (letter O), ':-8090', ':99999', or ':80-'. ParseUint(before, 10, 16) failing is the exact trigger.","commonSituations":"Using named ports ('http', 'https') which many tools accept but Caddy's parser does not; OCR/typo digits; copying URLs with schemes or paths into listen addresses.","solutions":["Replace service names with numbers: ':80' not ':http'.","Strip schemes/paths and keep only host:port or :port-range.","Verify both bounds are within 0-65535."],"exampleFix":"// before\naddr, err := caddy.ParseNetworkAddress(\":https\")\n// after\naddr, err := caddy.ParseNetworkAddress(\":443\")","handlingStrategy":"validation","validationCode":"var portRe = regexp.MustCompile(`^\\d{1,5}$`)\n\nfunc portLooksValid(p string) bool {\n    if !portRe.MatchString(p) { return false }\n    n, _ := strconv.Atoi(p)\n    return n <= 65535\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Translate service names to numbers in config generation (http->80, https->443).","Lint listen addresses to digits-only ports."],"tags":["port","parsing","validation","config"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}