{"record":{"id":"fefa22708e67086d","repo":"hashicorp/nomad","slug":"misconfigured-connection","errorCode":null,"errorMessage":"misconfigured connection","messagePattern":"misconfigured connection","errorType":"http","errorClass":"CodedError","httpStatus":500,"severity":"error","filePath":"command/agent/event_endpoint.go","lineNumber":85,"sourceCode":"\targs := &structs.EventStreamRequest{\n\t\tTopics: topics,\n\t\tIndex:  index,\n\t}\n\tresp.Header().Set(\"Content-Type\", \"application/json\")\n\tresp.Header().Set(\"Cache-Control\", \"no-cache\")\n\n\t// Set region, namespace and authtoken to args\n\ts.parse(resp, req, &args.QueryOptions.Region, &args.QueryOptions)\n\n\t// Determine the RPC handler to use to find a server\n\tvar handler structs.StreamingRpcHandler\n\tvar handlerErr error\n\tif server := s.agent.Server(); server != nil {\n\t\thandler, handlerErr = server.StreamingRpcHandler(\"Event.Stream\")\n\t} else if client := s.agent.Client(); client != nil {\n\t\thandler, handlerErr = client.RemoteStreamingRpcHandler(\"Event.Stream\")\n\t} else {\n\t\thandlerErr = fmt.Errorf(\"misconfigured connection\")\n\t}\n\n\tif handlerErr != nil {\n\t\treturn nil, CodedError(500, handlerErr.Error())\n\t}\n\n\thttpPipe, handlerPipe := net.Pipe()\n\tdecoder := codec.NewDecoder(httpPipe, structs.MsgpackHandle)\n\tencoder := codec.NewEncoder(httpPipe, structs.MsgpackHandle)\n\n\t// writeTimeout is set to 10 seconds more than the heartbeat of\n\t// NewJsonStream\n\twriteTimeout := 40 * time.Second\n\n\tctx, cancel := context.WithCancel(req.Context())\n\tdefer cancel()\n\n\tvar output io.WriteCloser","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/event_endpoint.go#L67-L103","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Enable a role in the agent config: set server { enabled = true } or client { enabled = true }.","Point your event stream consumer at a server or client agent instead of this node.","Restart the agent after fixing the config and retry the stream."],"exampleFix":"// before\n# agent.hcl: (no server/client block)\n// after\nclient { enabled = true }","handlingStrategy":"validation","validationCode":"// before consuming the event stream, confirm the agent has a role\n$ curl -s http://127.0.0.1:4646/v1/agent/self | jq '.config.Client.Enabled, .config.Server.Enabled'\n# at least one must be true","typeGuard":null,"tryCatchPattern":"try {\n  const stream = await fetch('/v1/event/stream?topic=*')\n} catch err {\n  if (err.status === 500 && err.body.includes('misconfigured connection')) {\n    console.error('target agent has neither server nor client enabled')\n  }\n}","preventionTips":["Always run agents with at least one of server or client enabled.","Point event-stream consumers at server or client agents, not infrastructure-only nodes.","Validate agent configs at startup (nomad agent -config ... ; check /v1/agent/self).","Add a readiness check on /v1/agent/self before opening streams."],"tags":["events","configuration","agent"],"backgroundTag":"misconfigured-agent-role","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}