{"record":{"id":"b3bca09150f86ee3","repo":"cloudflare/cloudflared","slug":"hostname-s-is-not-valid","errorCode":null,"errorMessage":"Hostname %s is not valid","messagePattern":"Hostname (.+?) is not valid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"validation/validation.go","lineNumber":56,"sourceCode":"\t\t}\n\t\thostnameToURL, err := url.Parse(unescapeHostname)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"Hostname(actually a URL) %s has invalid format %s\", hostname, hostnameToURL)\n\t\t}\n\t\tasciiHostname, err := idna.ToASCII(hostnameToURL.Hostname())\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"Hostname(actually a URL) %s has invalid ASCII encdoing %s\", hostname, asciiHostname)\n\t\t}\n\t\treturn asciiHostname, nil\n\t}\n\n\tasciiHostname, err := idna.ToASCII(hostname)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Hostname %s has invalid ASCII encdoing %s\", hostname, asciiHostname)\n\t}\n\thostnameToURL, err := url.Parse(asciiHostname)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Hostname %s is not valid\", hostnameToURL)\n\t}\n\treturn hostnameToURL.RequestURI(), nil\n\n}\n\n// ValidateUrl returns a validated version of `originUrl` with a scheme prepended (by default http://).\n// Note: when originUrl contains a scheme, the path is removed:\n//\n//\tValidateUrl(\"https://localhost:8080/api/\") => \"https://localhost:8080\"\n//\n// but when it does not, the path is preserved:\n//\n//\tValidateUrl(\"localhost:8080/api/\") => \"http://localhost:8080/api/\"\n//\n// This is arguably a bug, but changing it might break some cloudflared users.\nfunc ValidateUrl(originUrl string) (*url.URL, error) {\n\turlStr, err := validateUrlString(originUrl)\n\tif err != nil {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/validation/validation.go#L38-L74","documentation":"After IDNA conversion succeeds, ValidateHostname parses the ASCII hostname with url.Parse and returns its RequestURI. This error fires when the converted hostname cannot be parsed as a URL — a rare state indicating the IDNA output itself is structurally unparseable.","triggerScenarios":"Calling ValidateHostname with a plain hostname whose idna.ToASCII output fails url.Parse — e.g. pathological inputs where the punycode conversion yields control characters or the input contains characters url.Parse rejects.","commonSituations":"Hostnames with embedded characters that survive IDNA conversion but break URL parsing; extreme edge cases with mis-encoded byte sequences in config values.","solutions":["Verify the hostname is a simple ASCII name (letters, digits, hyphens, dots) and retry","Inspect the converted value (%s in the message) to see what IDNA produced and fix the original input","Pre-validate with url.Parse(idna.ToASCII(hostname)) before calling","Fall back to the IP address if hostname validation keeps failing"],"exampleFix":"// before\nhostname, err := validation.ValidateHostname(\"bad\\x00name\")\n// after\nhostname, err := validation.ValidateHostname(\"goodname.example.com\")","handlingStrategy":"validation","validationCode":"func parsesAsURL(h string) bool {\n    ascii, err := idna.ToASCII(h)\n    if err != nil { return false }\n    _, err = url.Parse(ascii)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":"host, err := validation.ValidateHostname(input)\nif err != nil {\n    if strings.Contains(err.Error(), \"is not valid\") {\n        return fmt.Errorf(\"hostname %q failed post-conversion URL parse\", input)\n    }\n    return err\n}","preventionTips":["Keep hostnames to simple ASCII forms","Pre-check with url.Parse(idna.ToASCII(h)) in config loading","Fall back to IP addresses for pathological inputs"],"tags":["hostname","validation","url"],"backgroundTag":"invalid-url-format","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}