nats-io/nats-server · error

duplicate remote %s

Error message

duplicate remote %s

What it means

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.

Source

Thrown at server/leafnode.go:227

	}

	if len(o.LeafNode.Remotes) > 0 {
		names := make(map[string]struct{})
		// Check for duplicate remotes, also, users can bind to any local account,
		// if its empty we will assume the $G account.
		for _, r := range o.LeafNode.Remotes {
			if r.LocalAccount == _EMPTY_ {
				r.LocalAccount = globalAccountName
			}
			if err := checkPermSubjectArray(r.DenyImports, false); err != nil {
				return fmt.Errorf("invalid deny_imports for remote %s: %w", r.safeName(), err)
			}
			if err := checkPermSubjectArray(r.DenyExports, false); err != nil {
				return fmt.Errorf("invalid deny_exports for remote %s: %w", r.safeName(), err)
			}
			rn := r.name()
			if _, dup := names[rn]; dup {
				return fmt.Errorf("duplicate remote %s", r.safeName())
			}
			names[rn] = struct{}{}
		}
	}

	// In local config mode, check that leafnode configuration refers to accounts that exist.
	if len(o.TrustedOperators) == 0 {
		accNames := map[string]struct{}{}
		for _, a := range o.Accounts {
			accNames[a.Name] = struct{}{}
		}
		// global account is always created
		accNames[DEFAULT_GLOBAL_ACCOUNT] = struct{}{}
		// in the context of leaf nodes, empty account means global account
		accNames[_EMPTY_] = struct{}{}
		// system account either exists or, if not disabled, will be created
		if o.SystemAccount == _EMPTY_ && !o.NoSystemAccount {
			accNames[DEFAULT_SYSTEM_ACCOUNT] = struct{}{}

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Give each remote a distinct local account
  2. Remove the duplicated remote entry
  3. Merge URL lists into a single remote for that account
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/leafnode.go:227 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02). Data as JSON: /api/errors/291b25a45ea02275. Report an issue: GitHub.