{"record":{"id":"9fe819f24a5e9a42","repo":"hashicorp/nomad","slug":"unable-to-parse-configured-address-v","errorCode":null,"errorMessage":"unable to parse configured address: %v","messagePattern":"unable to parse configured address: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/operator_api.go","lineNumber":441,"sourceCode":"\t\t!strings.HasPrefix(path, \"unix://\") {\n\t\tscheme := \"http\"\n\n\t\t// If the user has set any TLS configuration value, this is a good sign\n\t\t// Nomad is running with TLS enabled. Otherwise, use the address within\n\t\t// the config to identify a scheme.\n\t\tif config.TLSConfig.CACert != \"\" ||\n\t\t\tconfig.TLSConfig.CAPath != \"\" ||\n\t\t\tconfig.TLSConfig.ClientCert != \"\" ||\n\t\t\tconfig.TLSConfig.TLSServerName != \"\" ||\n\t\t\tconfig.TLSConfig.Insecure {\n\n\t\t\t// TLS configured, but scheme not set. Assume https.\n\t\t\tscheme = \"https\"\n\t\t} else if config.Address != \"\" {\n\n\t\t\tconfURL, err := url.Parse(config.Address)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"unable to parse configured address: %v\", err)\n\t\t\t}\n\n\t\t\t// Ensure we only overwrite the set scheme value if the parsing\n\t\t\t// identified a valid scheme.\n\t\t\tif confURL.Scheme == \"http\" || confURL.Scheme == \"https\" {\n\t\t\t\tscheme = confURL.Scheme\n\t\t\t}\n\t\t}\n\n\t\tpath = fmt.Sprintf(\"%s://%s\", scheme, path)\n\t}\n\n\tu, err := url.Parse(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// If URL.Host is empty, use defaults from client config.","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/operator_api.go#L423-L459","documentation":"pathToURL normalizes the API path into a full URL for `nomad operator api`. When the target URL has no scheme but a client Address is configured, it parses config.Address with url.Parse; a parse failure produces \"unable to parse configured address: %v\". This guards against garbage in the address configuration before it is used to derive the scheme.","triggerScenarios":"`nomad operator api ...` where the address to parse (config.Address from -address flag, NOMAD_ADDR env, or config file) is not a parseable URL — e.g. contains control characters, spaces, or an invalid scheme like `ht!tp://host:4646`.","commonSituations":"NOMAD_ADDR with typos or shell-interpolated junk; quoting mistakes in config files (HCL/JSON) embedding whitespace; scripts building the address with concatenation errors.","solutions":["Echo $NOMAD_ADDR and fix malformed characters; set a clean URL like http://127.0.0.1:4646.","Pass a valid -address flag to override the bad environment value.","Check client config files for stray whitespace/quotes around the address.","Ensure scheme is http:// or https:// and host:port form is valid."],"exampleFix":"// before (shell)\nexport NOMAD_ADDR=\"http://127.0.0.1:4646/ \"   # trailing junk\n// after\nexport NOMAD_ADDR=\"http://127.0.0.1:4646\"","handlingStrategy":"validation","validationCode":"// shell: sanity-check the address parses as a URL before invoking\ncase \"$NOMAD_ADDR\" in\n  http://*|https://*) : ;;\n  *) echo \"NOMAD_ADDR='$NOMAD_ADDR' is not a valid http(s) URL\"; exit 1 ;;\nesac","typeGuard":null,"tryCatchPattern":"// bash\nif ! out=$(nomad operator api \"$PATH\" 2>&1); then\n  case \"$out\" in *\"unable to parse configured address\"*) echo \"check NOMAD_ADDR: $NOMAD_ADDR\" ;; esac\nfi","preventionTips":["Quote NOMAD_ADDR assignments to avoid trailing whitespace.","Validate env vars in CI before running operator commands.","Build addresses with printf/host:port templates, not ad-hoc concatenation."],"tags":["cli","nomad","url-parsing","configuration"],"backgroundTag":"invalid-url","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"}