{"record":{"id":"e981a5887c61e8c0","repo":"hashicorp/nomad","slug":"unsupported-scheme-v","errorCode":null,"errorMessage":"unsupported scheme: %v","messagePattern":"unsupported scheme: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/api.go","lineNumber":991,"sourceCode":"\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tr.setQueryOptions(q)\n\n\trhttp, err := r.toHTTP()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\t// convert scheme\n\twsScheme := \"\"\n\tswitch rhttp.URL.Scheme {\n\tcase \"http\":\n\t\twsScheme = \"ws\"\n\tcase \"https\":\n\t\twsScheme = \"wss\"\n\tdefault:\n\t\treturn nil, nil, fmt.Errorf(\"unsupported scheme: %v\", rhttp.URL.Scheme)\n\t}\n\trhttp.URL.Scheme = wsScheme\n\n\tconn, resp, err := dialer.Dial(rhttp.URL.String(), rhttp.Header)\n\n\t// check resp status code, as it's more informative than handshake error we get from ws library\n\tif resp != nil {\n\t\tswitch resp.StatusCode {\n\t\tcase http.StatusSwitchingProtocols:\n\t\t\t// Connection upgrade was successful.\n\n\t\tcase http.StatusPermanentRedirect, http.StatusTemporaryRedirect, http.StatusMovedPermanently:\n\t\t\tloc := resp.Header.Get(\"Location\")\n\t\t\tu, err := url.Parse(loc)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"invalid redirect location %q: %w\", loc, err)\n\t\t\t}\n\t\t\treturn c.websocket(u.Path, q)","sourceCodeStart":973,"sourceCodeEnd":1009,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/api/api.go#L973-L1009","documentation":"In api/api.go:991, the websocket helper rewrites the request URL scheme http→ws and https→wss before dialing; any other scheme is rejected with this error. It means the websocket endpoint was reached with a URL scheme the client cannot translate to a websocket protocol.","triggerScenarios":"Calling websocket-based APIs (exec streaming, logs streaming) when the client's Address uses a scheme other than http/https — e.g. ws://, wss://, or a garbled scheme from bad configuration.","commonSituations":"Setting NOMAD_ADDR to \"wss://...\" assuming the client speaks raw websocket; a misconfigured proxy or service mesh rewriting the scheme; typos like \"htttp://\" reaching this switch.","solutions":["Set the client Address to http:// or https:// — the client converts to ws/wss automatically","Fix NOMAD_ADDR / Config.Address scheme and retry","Check any reverse proxy in front of Nomad preserves the http/https scheme in forwarded URLs","If the scheme originates from a redirect target, verify the upstream advertises http/https locations"],"exampleFix":"// before\ncfg.Address = \"wss://nomad.example.com\" // unsupported scheme\n// after\ncfg.Address = \"https://nomad.example.com\" // client upgrades to wss for websockets","handlingStrategy":"validation","validationCode":"u, err := url.Parse(cfg.Address)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\") {\n\treturn fmt.Errorf(\"Address must use http(s), got scheme %q\", u.Scheme)\n}","typeGuard":"func isHTTPOrHTTPS(addr string) bool {\n\tu, err := url.Parse(addr)\n\treturn err == nil && (u.Scheme == \"http\" || u.Scheme == \"https\")\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"unsupported scheme\") {\n\treturn fmt.Errorf(\"use http:// or https:// in NOMAD_ADDR (ws/wss are derived automatically): %w\", err)\n}","preventionTips":["Never set NOMAD_ADDR to ws:// or wss://","Validate the address scheme in config bootstrap","Ensure upstream proxies do not rewrite the scheme"],"tags":["websocket","url","configuration","nomad-api"],"backgroundTag":"unsupported-url-scheme","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"}