{"record":{"id":"768f1a076df87353","repo":"hashicorp/nomad","slug":"error-parsing-advertise-address-q-v","errorCode":null,"errorMessage":"Error parsing advertise address %q: %v","messagePattern":"Error parsing advertise address %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/config.go","lineNumber":2540,"sourceCode":"// If addr is not set and bind is a valid address, the returned string is the\n// bind+port.\n//\n// If addr is not set and bind is not a valid advertise address, the hostname\n// is resolved and returned with the port.\n//\n// Loopback is only considered a valid advertise address in dev mode.\nfunc normalizeAdvertise(addr string, bind string, defport int, dev bool) (string, error) {\n\taddr, err := listenerutil.ParseSingleIPTemplate(addr)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Error parsing advertise address template: %v\", err)\n\t}\n\n\tif addr != \"\" {\n\t\t// Default to using manually configured address\n\t\t_, _, err = net.SplitHostPort(addr)\n\t\tif err != nil {\n\t\t\tif !isMissingPort(err) && !isTooManyColons(err) {\n\t\t\t\treturn \"\", fmt.Errorf(\"Error parsing advertise address %q: %v\", addr, err)\n\t\t\t}\n\n\t\t\t// missing port, append the default\n\t\t\treturn normalizeAddrWithPort(addr, defport), nil\n\t\t}\n\n\t\treturn ipaddr.NormalizeAddr(addr), nil\n\t}\n\n\t// Fallback to bind address first, and then try resolving the local hostname\n\tips, err := net.LookupIP(bind)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Error resolving bind address %q: %v\", bind, err)\n\t}\n\n\t// Return the first non-localhost unicast address\n\tfor _, ip := range ips {\n\t\tif ip.IsLinkLocalUnicast() || ip.IsGlobalUnicast() {","sourceCodeStart":2522,"sourceCodeEnd":2558,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/config.go#L2522-L2558","documentation":"After template resolution, normalizeAdvertise() calls net.SplitHostPort on the advertise address. If that fails with an error other than a missing port or too many colons (e.g. an empty host), the address cannot be interpreted as host:port and this error wraps the underlying net error.","triggerScenarios":"advertise resolves to a string that is neither a valid host:port nor a bare host/IP — e.g. advertise = \"\" combined with failure paths, an address like \":8301\" (missing host is allowed by SplitHostPort? no — host missing yields 'missing port' style errors only for port), or addresses like \"host:\" handled elsewhere; specifically errors like 'too many colons' are filtered out, so any other SplitHostPort failure triggers this.","commonSituations":"Setting advertise to a value with stray characters (spaces, protocol prefixes like http://), or config interpolation producing an empty/garbage string.","solutions":["Set advertise to a plain form: bare IP (\"10.0.0.5\"), host:port (\"10.0.0.5:8301\"), or a resolvable hostname","Remove protocol prefixes, whitespace, or quotes embedded in the value","Check environment/config interpolation isn't producing an empty or malformed value","If using IPv6 literals, bracket them: \"[::1]:8301\""],"exampleFix":"// before\nadvertise = \"http://10.0.0.5\"\n// after\nadvertise = \"10.0.0.5:8301\"","handlingStrategy":"validation","validationCode":"if cfg.Advertise != \"\" {\n    if _, _, err := net.SplitHostPort(cfg.Advertise); err != nil {\n        return fmt.Errorf(\"invalid advertise %q: %w\", cfg.Advertise, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"_, _, err := net.SplitHostPort(cfg.Advertise)\nif err != nil && !isMissingPort(err) && !isTooManyColons(err) {\n    cfg.Advertise = net.JoinHostPort(defaultIP, \"8301\")\n}","preventionTips":["Always write advertise as bare IP, host, or host:port — no scheme prefixes","Bracket IPv6 literals","Run consul validate on configs before startup","Avoid shell interpolation that can inject empty strings"],"tags":["config","consul","address-parsing","advertise-address"],"backgroundTag":"invalid-address-format","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}