{"record":{"id":"bec2ebf8a6ed439d","repo":"grpc/grpc-go","slug":"delegating-resolver-failed-to-determine-proxy-url","errorCode":null,"errorMessage":"delegating_resolver: failed to determine proxy URL for target %q: %v","messagePattern":"delegating_resolver: failed to determine proxy URL for target %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/resolver/delegatingresolver/delegatingresolver.go","lineNumber":125,"sourceCode":"\tr := &delegatingResolver{\n\t\ttarget:         target,\n\t\tcc:             cc,\n\t\tproxyResolver:  nopResolver{},\n\t\ttargetResolver: nopResolver{},\n\t}\n\n\taddr := target.Endpoint()\n\tvar err error\n\tif target.URL.Scheme == \"dns\" && !targetResolutionEnabled && envconfig.EnableDefaultPortForProxyTarget {\n\t\taddr, err = parseTarget(addr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"delegating_resolver: invalid target address %q: %v\", target.Endpoint(), err)\n\t\t}\n\t}\n\n\tr.proxyURL, err = proxyURLForTarget(addr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"delegating_resolver: failed to determine proxy URL for target %q: %v\", target, err)\n\t}\n\n\t// proxy is not configured or proxy address excluded using `NO_PROXY` env\n\t// var, so only target resolver is used.\n\tif r.proxyURL == nil {\n\t\treturn targetResolverBuilder.Build(target, cc, opts)\n\t}\n\n\tif logger.V(2) {\n\t\tlogger.Infof(\"Proxy URL detected : %s\", r.proxyURL)\n\t}\n\n\t// Resolver updates from one child may trigger calls into the other. Block\n\t// updates until the children are initialized.\n\tr.childMu.Lock()\n\tdefer r.childMu.Unlock()\n\t// When the scheme is 'dns' and target resolution on client is not enabled,\n\t// resolution should be handled by the proxy, not the client. Therefore, we","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/internal/resolver/delegatingresolver/delegatingresolver.go#L107-L143","documentation":"Returned by New() when proxyURLForTarget(addr) (which calls http.ProxyFromEnvironment) returns an error. This happens when the HTTPS_PROXY/HTTP_PROXY environment variable is present but not a parseable URL, or NO_PROXY is malformed. The resolver cannot decide whether a proxy applies, so construction aborts.","triggerScenarios":"Setting HTTPS_PROXY to a value that is not a valid URL (e.g. missing scheme, unescaped spaces); setting http_proxy with a malformed authority; a NO_PROXY pattern that breaks url parsing in some Go versions.","commonSituations":"Proxy env var copied from a shell with stray quotes/whitespace; proxy string like \"proxy.corp:3128\" without the http:// scheme; CI that injects proxy vars in different formats across stages.","solutions":["Make HTTPS_PROXY/HTTP_PROXY a fully-qualified URL: \"http://proxy.corp:3128\".","Trim whitespace and stray quotes from proxy environment variables.","If no proxy is needed, unset HTTPS_PROXY and HTTP_PROXY (and rely on NO_PROXY if needed).","Validate the proxy URL with url.Parse at startup before dialing."],"exampleFix":"// before\nexport HTTPS_PROXY=proxy.corp:3128   // unparseable -> error\n// after\nexport HTTPS_PROXY=http://proxy.corp:3128","handlingStrategy":"validation","validationCode":"// Validate proxy env vars at startup.\nfunc checkProxy() error {\n    for _, e := range []string{\"HTTPS_PROXY\", \"HTTP_PROXY\", \"https_proxy\", \"http_proxy\"} {\n        if v := os.Getenv(e); v != \"\" {\n            if _, err := url.Parse(v); err != nil {\n                return fmt.Errorf(\"%s unparseable: %w\", e, err)\n            }\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"conn, err := grpc.Dial(target, ...)\nif err != nil && strings.Contains(err.Error(), \"failed to determine proxy URL\") {\n    // Clear the bad proxy var and retry without a proxy.\n    os.Unsetenv(\"HTTPS_PROXY\")\n}","preventionTips":["Always include the scheme in HTTPS_PROXY (http://...).","Trim whitespace and quotes from proxy env vars in container setup.","Add a startup self-test that url.Parse's every proxy-related env var."],"tags":["grpc","resolver","delegating-resolver","proxy","environment","configuration"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}