derailed/k9s · error
no connection to cached dial
Error message
no connection to cached dial
What it means
Returned by APIClient.CachedDiscovery (internal/client/client.go:491) when connOK is false. This method builds a disk-cached discovery client (cache dir from KUBECACHEDIR or the default http cache dir) used for GVR resolution and resource mapping. Like Dial/DialLogs it is gated on the shared connection-health flag, so any earlier failed probe blocks it.
Source
Thrown at internal/client/client.go:491
}
c, err := kubernetes.NewForConfig(cfg)
if err != nil {
return nil, err
}
a.setClient(c)
return a.getClient(), nil
}
// RestConfig returns a rest api client.
func (a *APIClient) RestConfig() (*restclient.Config, error) {
return a.config.RESTConfig()
}
// CachedDiscovery returns a cached discovery client.
func (a *APIClient) CachedDiscovery() (*disk.CachedDiscoveryClient, error) {
if !a.getConnOK() {
return nil, errors.New("no connection to cached dial")
}
if c := a.getCachedClient(); c != nil {
return c, nil
}
cfg, err := a.RestConfig()
if err != nil {
return nil, err
}
baseCacheDir := os.Getenv("KUBECACHEDIR")
if baseCacheDir == "" {
baseCacheDir = filepath.Join(mustHomeDir(), ".kube", "cache")
}
httpCacheDir := filepath.Join(baseCacheDir, "http")
discCacheDir := filepath.Join(baseCacheDir, "discovery", toHostDir(cfg.Host))View on GitHub (pinned to 2d3ccc6ba2)
Solutions
- Run CheckConnectivity() and only call CachedDiscovery() when it returns true
- Fix the kubeconfig/credentials that made the initial probe fail, then re-init the client
- Optionally set KUBECACHEDIR to a writable directory so the disk cache itself cannot fail afterwards
Example fix
// before
dd, err := apiClient.CachedDiscovery()
// after
if apiClient.CheckConnectivity() {
dd, err := apiClient.CachedDiscovery()
} Defensive patterns
Strategy: validation
Validate before calling
if !apiClient.CheckConnectivity() {
return nil, errors.New("discovery unavailable: no connection")
}
dd, err := apiClient.CachedDiscovery() Try / catch
dd, err := apiClient.CachedDiscovery()
if err != nil && strings.Contains(err.Error(), "no connection to cached dial") {
// reconnect, then retry once; discovery is safe to retry (idempotent)
} Prevention
- Resolve GVRs once at startup via CachedDiscovery after connectivity is confirmed
- Set KUBECACHEDIR to a writable path so cache writes never compound the failure
- Watch for apiservice churn and re-run discovery lazily, not per keystroke
When it happens
Trigger: Calling CachedDiscovery() after the connection was marked down, or before the first successful connection. Also triggered when RESTConfig() fails (bad kubeconfig) because CheckConnectivity sets connOK=false in that path.
Common situations: Resource listing or GVR lookups immediately after a network interruption; read-only kubeconfig with a broken certificate path; stale KUBECACHEDIR on a read-only filesystem; session resumed after cluster credentials rotated.
Related errors
- ACCESS -- No API server connection
- dialLogs - no connection to dial
- no connection to dial
- no metrics-server detected on cluster
- failed to locate pod %q: %w
AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15).
Data as JSON: /api/errors/1934cb80e5352058.
Report an issue: GitHub.