{"record":{"id":"291b25a45ea02275","repo":"nats-io/nats-server","slug":"duplicate-remote-s","errorCode":null,"errorMessage":"duplicate remote %s","messagePattern":"duplicate remote (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/leafnode.go","lineNumber":227,"sourceCode":"\t}\n\n\tif len(o.LeafNode.Remotes) > 0 {\n\t\tnames := make(map[string]struct{})\n\t\t// Check for duplicate remotes, also, users can bind to any local account,\n\t\t// if its empty we will assume the $G account.\n\t\tfor _, r := range o.LeafNode.Remotes {\n\t\t\tif r.LocalAccount == _EMPTY_ {\n\t\t\t\tr.LocalAccount = globalAccountName\n\t\t\t}\n\t\t\tif err := checkPermSubjectArray(r.DenyImports, false); err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid deny_imports for remote %s: %w\", r.safeName(), err)\n\t\t\t}\n\t\t\tif err := checkPermSubjectArray(r.DenyExports, false); err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid deny_exports for remote %s: %w\", r.safeName(), err)\n\t\t\t}\n\t\t\trn := r.name()\n\t\t\tif _, dup := names[rn]; dup {\n\t\t\t\treturn fmt.Errorf(\"duplicate remote %s\", r.safeName())\n\t\t\t}\n\t\t\tnames[rn] = struct{}{}\n\t\t}\n\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{}{}","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/leafnode.go#L209-L245","documentation":"Leafnode configuration validation: two remotes declare the same local account, which would create ambiguous routing for that account's leaf traffic; the duplicate is rejected at options validation.","triggerScenarios":"Thrown at server/leafnode.go:227 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Give each remote a distinct local account","Remove the duplicated remote entry","Merge URL lists into a single remote for that account"],"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"}