{"record":{"id":"87a570ea015312cc","repo":"cloudflare/cloudflared","slug":"not-a-valid-host","errorCode":null,"errorMessage":"not a valid host","messagePattern":"not a valid host","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/access/cmd.go","lineNumber":502,"sourceCode":"func parseAllowRequest(cmdArgs []string) ([]string, bool) {\n\tif len(cmdArgs) > 1 {\n\t\tif cmdArgs[0] == \"--allow-request\" || cmdArgs[0] == \"-ar\" {\n\t\t\treturn cmdArgs[1:], true\n\t\t}\n\t}\n\n\treturn cmdArgs, false\n}\n\n// processURL will preprocess the string (parse to a url, convert to punycode, etc).\nfunc processURL(s string) (*url.URL, error) {\n\tu, err := url.ParseRequestURI(s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif u.Host == \"\" {\n\t\treturn nil, errors.New(\"not a valid host\")\n\t}\n\n\thost, err := idna.ToASCII(u.Hostname())\n\tif err != nil { // we fail to convert to punycode, just return the url we parsed.\n\t\treturn u, nil\n\t}\n\tif u.Port() != \"\" {\n\t\tu.Host = fmt.Sprintf(\"%s:%s\", host, u.Port())\n\t} else {\n\t\tu.Host = host\n\t}\n\n\treturn u, nil\n}\n\n// cloudflaredPath pulls the full path of cloudflared on disk\nfunc cloudflaredPath() string {\n\tpath, err := os.Executable()","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/access/cmd.go#L484-L520","documentation":"processURL parses the user-supplied URL with url.ParseRequestURI and then requires a non-empty Host component; an empty host yields this error. It means the string was parseable as a URI but lacked an authority, so an Access token cannot be fetched for it.","triggerScenarios":"Passing URLs without a host to `cloudflared access curl`, e.g. \"/api/endpoint\", \"app.example.com/route\" (no scheme but treated as a path), or an accidentally truncated URL like \"https://\".","commonSituations":"Omitting the scheme so the host becomes part of the path; passing a relative path copied from browser devtools; shell splitting a URL containing special characters; trailing-slash/whitespace truncation in scripts.","solutions":["Include the full scheme and host: use https://app.example.com/path instead of app.example.com/path","Quote the URL in the shell to prevent splitting/truncation","Check for stray characters or line breaks that truncated the URL","Verify with a quick parse (e.g. `python3 -c \"import urllib.parse;print(urllib.parse.urlparse('YOUR_URL').netloc)\"`) that a host is present"],"exampleFix":"// before\n# cloudflared access curl app.example.com\n// after\n# cloudflared access curl https://app.example.com","handlingStrategy":"validation","validationCode":"u, err := url.ParseRequestURI(target)\nif err != nil || u.Host == \"\" {\n    return fmt.Errorf(\"%q must be an absolute URL with a host, e.g. https://app.example.com\", target)\n}","typeGuard":null,"tryCatchPattern":"u, err := processURL(target)\nif err != nil {\n    if strings.Contains(err.Error(), \"not a valid host\") {\n        return fmt.Errorf(\"URL %q is missing a host; include the scheme (https://...): %w\", target, err)\n    }\n    return err\n}","preventionTips":["Always use absolute URLs including the https:// scheme","Quote URLs in shells to avoid truncation/splitting","Copy full URLs from the browser address bar, not relative paths","Trim whitespace and control characters from user-supplied URLs"],"tags":["url","validation","access","cli"],"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"}