derailed/k9s · error
unable to locate node %s
Error message
unable to locate node %s
What it means
Node.Get lists all nodes and scans for one whose name matches path; when no entry matches it returns this error. The List call succeeded, so this is strictly a name-mismatch / not-found-after-list failure, not an RBAC or connectivity problem.
Source
Thrown at internal/dao/node.go:147
return nil
}
// Get returns a node resource.
func (n *Node) Get(ctx context.Context, path string) (runtime.Object, error) {
oo, err := n.Resource.List(ctx, "")
if err != nil {
return nil, err
}
var raw *unstructured.Unstructured
for _, o := range oo {
if u, ok := o.(*unstructured.Unstructured); ok && u.GetName() == path {
raw = u
}
}
if raw == nil {
return nil, fmt.Errorf("unable to locate node %s", path)
}
var nmx *mv1beta1.NodeMetrics
if withMx, ok := ctx.Value(internal.KeyWithMetrics).(bool); ok && withMx {
nmx, _ = client.DialMetrics(n.Client()).FetchNodeMetrics(ctx, path)
}
podCount := -1
if shouldCountPods, _ := ctx.Value(internal.KeyPodCounting).(bool); shouldCountPods {
if pp, err := n.GetPods(path); err == nil {
podCount = len(pp)
}
}
return &render.NodeWithMetrics{Raw: raw, MX: nmx, PodCount: podCount}, nil
}
// List returns a collection of node resources.View on GitHub (pinned to 2d3ccc6ba2)
Solutions
- Verify the node exists in the same context: kubectl get nodes | grep <name>
- Refresh/relist (reopen the view or restart the session) and retry once
- Check the kubeconfig context — the name may belong to another cluster
Defensive patterns
Strategy: retry
Validate before calling
nodes, err := dao.FetchNodes(ctx, factory, "")
if err != nil { return err }
found := false
for _, nn := range nodes.Items {
if nn.Name == name { found = true; break }
}
if !found { return fmt.Errorf("node %q not present in cluster", name) } Try / catch
if _, err := nodeDAO.Get(ctx, path); err != nil {
if strings.Contains(err.Error(), "unable to locate node") {
// one refresh + retry; after that surface 'node not found' to the user
}
} Prevention
- Validate node names against a fresh node list before acting on user input or saved picks
- Re-check existence after long-lived sessions resume (sleep/VPN) — caches go stale
- Confirm the kubeconfig context matches the cluster the name came from
When it happens
Trigger: Node deleted (or recreated under a new name) between the list and the lookup; stale or mistyped node name; the DAO cache not yet synced after cluster changes.
Common situations: Autocomplete or saved reference from a previous session/cluster; node removed while a k9s session stayed open; kubeconfig context pointing at a different cluster that does not have that node.
Related errors
- no connection to cached dial
- node is cordoned
- failed to locate pod %q: %w
- node is already cordoned
- node is already uncordoned
AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15).
Data as JSON: /api/errors/13acd7fda2fa5c1e.
Report an issue: GitHub.