nats-io/nats-server · error

remote leaf node configuration cannot have a mix of websocke

Error message

remote leaf node configuration cannot have a mix of websocket and non-websocket urls: %q

What it means

Leafnode remote validation: within a single remote's URL list, some URLs use the ws/wss scheme and others do not; a leaf connection must be uniformly websocket or plain TCP across the failover list.

Source

Thrown at server/leafnode.go:310

	// If a remote has a websocket scheme, all need to have it.
	for _, rcfg := range o.LeafNode.Remotes {
		// Validate proxy configuration
		if _, err := validateLeafNodeProxyOptions(rcfg); err != nil {
			return err
		}

		if len(rcfg.URLs) >= 2 {
			firstIsWS, ok := isWSURL(rcfg.URLs[0]), true
			for i := 1; i < len(rcfg.URLs); i++ {
				u := rcfg.URLs[i]
				if isWS := isWSURL(u); isWS && !firstIsWS || !isWS && firstIsWS {
					ok = false
					break
				}
			}
			if !ok {
				return fmt.Errorf("remote leaf node configuration cannot have a mix of websocket and non-websocket urls: %q", redactURLList(rcfg.URLs))
			}
		}
		if !wsAllowedFIPS() {
			for _, u := range rcfg.URLs {
				if isWSURL(u) {
					return fmt.Errorf("remote leaf node URL %q cannot be used in FIPS-140 mode when built with this Go version, use Go 1.26 or later", redactURLString(u.String()))
				}
			}
		}
		// Validate compression settings
		if rcfg.Compression.Mode != _EMPTY_ {
			if err := validateAndNormalizeCompressionOption(&rcfg.Compression, CompressionS2Auto); err != nil {
				return err
			}
		}
	}

	if o.LeafNode.Port == 0 {

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Split websocket and non-websocket URLs into separate remotes
  2. Convert all URLs in the list to ws:// or wss://
  3. Remove mismatched URLs from the remote
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/leafnode.go:310 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/2943058ef449a582. Report an issue: GitHub.