hashicorp/nomad · error · CodedError

misconfigured connection

Error message

misconfigured connection

What it means

The EventStream HTTP streaming endpoint requires either a Nomad server or a Nomad client to obtain the Event.Stream RPC handler. If the agent has neither (no server and no client component), the connection itself is misconfigured and the handler cannot be resolved, returning HTTP 500.

Source

Thrown at command/agent/event_endpoint.go:85

	args := &structs.EventStreamRequest{
		Topics: topics,
		Index:  index,
	}
	resp.Header().Set("Content-Type", "application/json")
	resp.Header().Set("Cache-Control", "no-cache")

	// Set region, namespace and authtoken to args
	s.parse(resp, req, &args.QueryOptions.Region, &args.QueryOptions)

	// Determine the RPC handler to use to find a server
	var handler structs.StreamingRpcHandler
	var handlerErr error
	if server := s.agent.Server(); server != nil {
		handler, handlerErr = server.StreamingRpcHandler("Event.Stream")
	} else if client := s.agent.Client(); client != nil {
		handler, handlerErr = client.RemoteStreamingRpcHandler("Event.Stream")
	} else {
		handlerErr = fmt.Errorf("misconfigured connection")
	}

	if handlerErr != nil {
		return nil, CodedError(500, handlerErr.Error())
	}

	httpPipe, handlerPipe := net.Pipe()
	decoder := codec.NewDecoder(httpPipe, structs.MsgpackHandle)
	encoder := codec.NewEncoder(httpPipe, structs.MsgpackHandle)

	// writeTimeout is set to 10 seconds more than the heartbeat of
	// NewJsonStream
	writeTimeout := 40 * time.Second

	ctx, cancel := context.WithCancel(req.Context())
	defer cancel()

	var output io.WriteCloser

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Enable a role in the agent config: set server { enabled = true } or client { enabled = true }.
  2. Point your event stream consumer at a server or client agent instead of this node.
  3. Restart the agent after fixing the config and retry the stream.

Example fix

// before
# agent.hcl: (no server/client block)
// after
client { enabled = true }
Defensive patterns

Strategy: validation

Validate before calling

// before consuming the event stream, confirm the agent has a role
$ curl -s http://127.0.0.1:4646/v1/agent/self | jq '.config.Client.Enabled, .config.Server.Enabled'
# at least one must be true

Try / catch

try {
  const stream = await fetch('/v1/event/stream?topic=*')
} catch err {
  if (err.status === 500 && err.body.includes('misconfigured connection')) {
    console.error('target agent has neither server nor client enabled')
  }
}

Prevention

When it happens

Trigger: Hitting the /v1/event/stream endpoint on an agent whose configuration left it with neither a server nor client role (both server.enabled=false and client.enabled=false), so agent.Server() and agent.Client() are both nil.

Common situations: Hand-edited agent config disabling both roles; proxy/misconfigured agent binary started with an empty config; connecting the event stream to an agent intended only for internal plumbing.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/fefa22708e67086d. Report an issue: GitHub.