{"record":{"id":"a43f4f9ef3a94856","repo":"nats-io/nats-server","slug":"cannot-find-local-account-q-specified-in-leafnode","errorCode":null,"errorMessage":"cannot find local account %q specified in leafnode %s","messagePattern":"cannot find local account %q specified in leafnode (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/leafnode.go","lineNumber":249,"sourceCode":"\t}\n\n\t// In local config mode, check that leafnode configuration refers to accounts that exist.\n\tif len(o.TrustedOperators) == 0 {\n\t\taccNames := map[string]struct{}{}\n\t\tfor _, a := range o.Accounts {\n\t\t\taccNames[a.Name] = struct{}{}\n\t\t}\n\t\t// global account is always created\n\t\taccNames[DEFAULT_GLOBAL_ACCOUNT] = struct{}{}\n\t\t// in the context of leaf nodes, empty account means global account\n\t\taccNames[_EMPTY_] = struct{}{}\n\t\t// system account either exists or, if not disabled, will be created\n\t\tif o.SystemAccount == _EMPTY_ && !o.NoSystemAccount {\n\t\t\taccNames[DEFAULT_SYSTEM_ACCOUNT] = struct{}{}\n\t\t}\n\t\tcheckAccountExists := func(accName string, cfgType string) error {\n\t\t\tif _, ok := accNames[accName]; !ok {\n\t\t\t\treturn fmt.Errorf(\"cannot find local account %q specified in leafnode %s\", accName, cfgType)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t\tif err := checkAccountExists(o.LeafNode.Account, \"authorization\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor _, lu := range o.LeafNode.Users {\n\t\t\tif lu.Account == nil { // means global account\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif err := checkAccountExists(lu.Account.Name, \"authorization\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tfor _, r := range o.LeafNode.Remotes {\n\t\t\tif err := checkAccountExists(r.LocalAccount, \"remote\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/leafnode.go#L231-L267","documentation":"Leafnode validation in local (non-operator) config mode: checkAccountExists could not find the named account among configured accounts (users, authorization account, or a remote's local account), so the leafnode references an unknown account.","triggerScenarios":"Thrown at server/leafnode.go:249 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define the account in the accounts section","Fix the account name/key in the leafnode config","Remove the stale reference"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}