{"record":{"id":"f8400846c250eb6b","repo":"nats-io/nats-server","slug":"unable-to-add-account-q-to-the-list-of-dedicated","errorCode":null,"errorMessage":"unable to add account %q to the list of dedicated routes: %v","messagePattern":"unable to add account %q to the list of dedicated routes: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/reload.go","lineNumber":1704,"sourceCode":"\t\tcase \"nkeys\":\n\t\t\tdiffOpts = append(diffOpts, &nkeysOption{})\n\t\tcase \"cluster\":\n\t\t\tnewClusterOpts := newValue.(ClusterOpts)\n\t\t\toldClusterOpts := oldValue.(ClusterOpts)\n\t\t\tif err := validateClusterOpts(oldClusterOpts, newClusterOpts); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tco := &clusterOption{\n\t\t\t\tnewValue:        newClusterOpts,\n\t\t\t\tpermsChanged:    !reflect.DeepEqual(newClusterOpts.Permissions, oldClusterOpts.Permissions),\n\t\t\t\tcompressChanged: !oldClusterOpts.Compression.equals(&newClusterOpts.Compression),\n\t\t\t}\n\t\t\tco.diffPoolAndAccounts(&oldClusterOpts)\n\t\t\t// If there are added accounts, first make sure that we can look them up.\n\t\t\t// If we can't let's fail the reload.\n\t\t\tfor _, acc := range co.accsAdded {\n\t\t\t\tif _, err := s.LookupAccount(acc); err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"unable to add account %q to the list of dedicated routes: %v\", acc, err)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If pool_size has been set to negative (but was not before), then let's\n\t\t\t// add the system account to the list of removed accounts (we don't have\n\t\t\t// to check if already there, duplicates are ok in that case).\n\t\t\tif newClusterOpts.PoolSize < 0 && oldClusterOpts.PoolSize >= 0 {\n\t\t\t\tif sys := s.SystemAccount(); sys != nil {\n\t\t\t\t\tco.accsRemoved = append(co.accsRemoved, sys.GetName())\n\t\t\t\t}\n\t\t\t}\n\t\t\tdiffOpts = append(diffOpts, co)\n\t\tcase \"routes\":\n\t\t\tadd, remove := diffRoutes(oldValue.([]*url.URL), newValue.([]*url.URL))\n\t\t\tdiffOpts = append(diffOpts, &routesOption{add: add, remove: remove})\n\t\tcase \"maxconn\":\n\t\t\tdiffOpts = append(diffOpts, &maxConnOption{newValue: newValue.(int)})\n\t\tcase \"pidfile\":\n\t\t\tdiffOpts = append(diffOpts, &pidFileOption{newValue: newValue.(string)})","sourceCodeStart":1686,"sourceCodeEnd":1722,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/reload.go#L1686-L1722","documentation":"During cluster options reload, newly added dedicated-reserve/pool accounts (co.accsAdded) are validated with s.LookupAccount. If an added account cannot be resolved, reload fails, wrapping the lookup error, because routes require the account to exist.","triggerScenarios":"cluster.pool_size / dedicated cluster accounts changed so that new accounts are added, but LookupAccount(name) fails — the account is not defined or not yet resolvable (no resolver hit, or listed only in the new config's removed/added sets inconsistently).","commonSituations":"Setting cluster { pool_size: -N } with accounts not defined in `accounts{}`; misspelled account names in cluster resolvers; memory resolver config missing the referenced account.","solutions":["Define the referenced accounts in the accounts{} block (or resolver) so LookupAccount succeeds, then reload again.","Fix the account name typo in the cluster dedicated accounts list.","Check resolver setup (memory resolver payload / URL resolver) includes the new accounts and the resolver is reachable.","Revert the pool/account change if the accounts cannot be provisioned yet."],"exampleFix":"// before\ncluster { pool_size: 2 } // account \"missing_acc\" not defined\n// after\naccounts { missing_acc { users: [...] } }\ncluster { pool_size: 2 }","handlingStrategy":"validation","validationCode":"for _, accName := range newClusterDedicatedAccounts {\n    if _, err := srv.LookupAccount(accName); err != nil {\n        return fmt.Errorf(\"account %q must be defined before reload\", accName)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := srv.Reload(); err != nil {\n    if strings.Contains(err.Error(), \"dedicated routes\") {\n        log.Printf(\"add missing accounts and reload again: %v\", err)\n    }\n}","preventionTips":["Define all cluster pool/dedicated accounts in accounts{} or the resolver before reload.","Validate account names with the resolver before issuing SIGHUP.","Avoid negative pool_size changes referencing undefined accounts."],"tags":["reload","cluster","account-lookup"],"backgroundTag":"account-not-found","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}