{"record":{"id":"121b25243270d25a","repo":"hashicorp/nomad","slug":"invalid-consul-connect-configuration-for-service","errorCode":null,"errorMessage":"invalid Consul Connect configuration for service %q: %v","messagePattern":"invalid Consul Connect configuration for service %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/consul/service_client.go","lineNumber":1350,"sourceCode":"\t\tservice.Address, addrMode, service.PortLabel, workload.Networks, workload.DriverNetwork, workload.Ports, workload.NetworkStatus)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get address for service %q: %v\", service.Name, err)\n\t}\n\n\t// Determine whether to use tags or canary_tags\n\tvar tags []string\n\tif workload.Canary && len(service.CanaryTags) > 0 {\n\t\ttags = make([]string, len(service.CanaryTags))\n\t\tcopy(tags, service.CanaryTags)\n\t} else {\n\t\ttags = make([]string, len(service.Tags))\n\t\tcopy(tags, service.Tags)\n\t}\n\n\t// newConnect returns (nil, nil) if there's no Connect-enabled service.\n\tconnect, err := newConnect(id, workload.AllocInfo, service.Name, service.Connect, workload.Networks, workload.Ports)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid Consul Connect configuration for service %q: %v\", service.Name, err)\n\t}\n\n\t// newConnectGateway returns nil if there's no Connect gateway.\n\tgateway := newConnectGateway(service.Connect)\n\n\t// newWeights returns nil if there's no Weights.\n\tweights := newWeights(service.Weights)\n\n\t// Determine whether to use meta or canary_meta\n\tvar meta map[string]string\n\tif workload.Canary && len(service.CanaryMeta) > 0 {\n\t\tmeta = make(map[string]string, len(service.CanaryMeta)+1)\n\t\tmaps.Copy(meta, service.CanaryMeta)\n\t} else {\n\t\tmeta = make(map[string]string, len(service.Meta)+1)\n\t\tmaps.Copy(meta, service.Meta)\n\t}\n","sourceCodeStart":1332,"sourceCodeEnd":1368,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/consul/service_client.go#L1332-L1368","documentation":"newConnect builds the Consul Connect SidecarService registration block for a Connect-enabled service; if the Connect configuration cannot be translated into a valid Consul registration (bad connect stanza, invalid sidecar port, incompatible workload networks), this wrapper aborts the service registration. It only fires for services that declare a Connect block.","triggerScenarios":"service.Connect is non-nil but newConnect(id, allocInfo, name, connect, networks, ports) returns an error — e.g. the Connect sidecar_service references a missing port, the sidecar task stanza is invalid, or the service group has no usable network for the envoy proxy.","commonSituations":"Consul Connect block with sidecar_service.port referencing a nonexistent port label; connect { sidecar_task {} } with invalid resources; envoy settings incompatible with the Consul version; missing network declaration in the group.","solutions":["Fix the connect block per the wrapped error — most often the sidecar port or missing group network declaration","Ensure the task group declares a network with the ports referenced by sidecar_service","Validate connect { sidecar_task {} } resource/config options against your Consul/Nomad version","Temporarily remove the connect block to isolate which field is invalid, then re-add"],"exampleFix":"// before\nconnect {\n  sidecar_service {\n    port = \"proxy\" // not declared\n  }\n}\n// after\nnetwork {\n  port \"proxy\" {}\n}\nconnect {\n  sidecar_service {\n    port = \"proxy\"\n  }\n}","handlingStrategy":"validation","validationCode":"// Validate connect sidecar references before submit\nif svc.Connect != nil && svc.Connect.SidecarService != nil {\n  if p := svc.Connect.SidecarService.Port; p != \"\" {\n    if _, ok := ports[p]; !ok {\n      return fmt.Errorf(\"connect sidecar port %q not declared\", p)\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare a network port for the proxy in the group network block","Keep connect blocks to the documented sidecar_service/sidecar_task fields","Match envoy options to your Consul version","Test connect jobs with `nomad job validate` first"],"tags":["consul","nomad","consul-connect","sidecar"],"backgroundTag":"invalid-connect-configuration","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"}