VictoriaMetrics/VictoriaMetrics · error
cannot create client for
Error message
cannot create client for %q: %w
What it means
This error wraps any failure from discoveryutil.NewClient when building the HTTP client used to talk to the Vultr API. NewClient validates proxy auth configs and the HTTP client config (TLS, headers, etc.), so the error means the transport layer for reaching apiServer could not be constructed. It is thrown eagerly at SD-config processing time, before any scrape happens.
Solutions
- Check the wrapped %w cause: it names the exact field (proxy auth, TLS, authorization) that failed to parse.
- Verify proxy_url and its proxy_*_auth credentials are correct and the scheme is http/https.
- Ensure all files referenced by http_client_config TLS settings exist and are readable from baseDir.
- Remove or fix unsupported http_client_config fields; test the config with a minimal SDConfig first.
Example fix
// before proxy_url: "http://bad-scheme-proxy.internal:3128" // after proxy_url: "http://proxy.internal:3128" proxy_basic_auth: username: "scraper" password_file: "proxy_password"
Defensive patterns
Strategy: validation
Validate before calling
if cfg.ProxyURL != "" {
u, err := url.Parse(cfg.ProxyURL)
if err != nil || (u.Scheme != "http" && u.Scheme != "https") {
return fmt.Errorf("invalid proxy_url %q", cfg.ProxyURL)
}
}
for _, f := range []string{cfg.HTTPClientConfig.TLSConfig.CAFile, cfg.HTTPClientConfig.TLSConfig.CertFile, cfg.HTTPClientConfig.TLSConfig.KeyFile} {
if f != "" {
if _, err := os.Stat(filepath.Join(baseDir, f)); err != nil {
return fmt.Errorf("TLS/auth file missing: %s", f)
}
}
} Prevention
- Keep proxy and TLS file paths relative to baseDir and verify them in CI config linting
- Use secrets mounted at stable paths with correct permissions
- Test SD configs with minimal fields before adding proxy/TLS options
When it happens
Trigger: Invalid proxy_url with bad credentials or unsupported scheme in the SDConfig; invalid http_client_config (bad TLS CA/cert/key files, malformed authorization block, bad oauth2 settings); apiServer URL that NewClient cannot handle.
Common situations: Typo in proxy credentials or proxy_basic_auth username/password; TLS ca/cert files referenced with paths that do not exist relative to baseDir; copying a Prometheus-style http_client_config with unsupported fields; environment where the proxy requires auth that was not configured.
Related errors
- cannot build auth client
- cannot create HTTP client for
- cannot get API config
- cannot build kubeConfig from
- cannot create HTTP client for
AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03).
Data as JSON: /api/errors/334d99d120a808f8.
Report an issue: GitHub.
Appendix: source
Thrown at lib/promscrape/discovery/vultr/api.go:52
// See: https://www.vultr.com/api/
apiServer := "https://api.vultr.com"
if sdc.HTTPClientConfig.BearerToken == nil {
return nil, fmt.Errorf("missing `bearer_token` option")
}
ac, err := sdc.HTTPClientConfig.NewConfig(baseDir)
if err != nil {
return nil, fmt.Errorf("cannot parse auth config: %w", err)
}
proxyAC, err := sdc.ProxyClientConfig.NewConfig(baseDir)
if err != nil {
return nil, fmt.Errorf("cannot parse proxy auth config: %w", err)
}
c, err := discoveryutil.NewClient(apiServer, ac, sdc.ProxyURL, proxyAC, &sdc.HTTPClientConfig)
if err != nil {
return nil, fmt.Errorf("cannot create client for %q: %w", apiServer, err)
}
// Prepare additional query params for list instance API.
// See https://www.vultr.com/api/#tag/instances/operation/list-instances
var qp url.Values
if sdc.Label != "" {
qp.Set("label", sdc.Label)
}
if sdc.MainIP != "" {
qp.Set("main_ip", sdc.MainIP)
}
if sdc.Region != "" {
qp.Set("region", sdc.Region)
}
if sdc.FirewallGroupID != "" {
qp.Set("firewall_group_id", sdc.FirewallGroupID)
}
if sdc.Hostname != "" {View on GitHub (pinned to 5079fb58f1)