{"record":{"id":"c776546e0c315f1b","repo":"hashicorp/nomad","slug":"error-getting-address-for-check-q-v","errorCode":null,"errorMessage":"error getting address for check %q: %v","messagePattern":"error getting address for check %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/consul/service_client.go","lineNumber":1515,"sourceCode":"\t\t\t}\n\n\t\t\taddrMode := check.AddressMode\n\t\t\tif addrMode == \"\" {\n\t\t\t\tif service.Address != \"\" {\n\t\t\t\t\t// if the service is using a custom address, enable the check\n\t\t\t\t\t// to use that address\n\t\t\t\t\taddrMode = structs.AddressModeAuto\n\t\t\t\t} else {\n\t\t\t\t\t// otherwise default to the host address\n\t\t\t\t\taddrMode = structs.AddressModeHost\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar err error\n\t\t\tip, port, err = serviceregistration.GetAddress(\n\t\t\t\tservice.Address, addrMode, portLabel, workload.Networks, workload.DriverNetwork, workload.Ports, workload.NetworkStatus)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error getting address for check %q: %v\", check.Name, err)\n\t\t\t}\n\t\t}\n\n\t\tcheckID := MakeCheckID(serviceID, check)\n\t\tregistration, err := createCheckReg(serviceID, checkID, check, ip, port, workload.ProviderNamespace)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to add check %q: %v\", check.Name, err)\n\t\t}\n\t\tsreg.CheckOnUpdate[checkID] = check.OnUpdate\n\t\tregistrations = append(registrations, registration)\n\t}\n\n\treturn registrations, nil\n}\n\n// RegisterWorkload with Consul. Adds all service entries and checks to Consul.\n//\n// If the service IP is set it used as the address in the service registration.","sourceCodeStart":1497,"sourceCodeEnd":1533,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/consul/service_client.go#L1497-L1533","documentation":"For each task-level check that specifies its own address_mode or port label differing from the service, Nomad calls serviceregistration.GetAddress to resolve the check's host/port. Failures (unknown port label, unsupported address mode, no matching network) are wrapped in this message and the whole set of registrations fails to build.","triggerScenarios":"BuildRegistrations loop reaches a check whose address must be resolved independently and GetAddress(service.Address, addrMode, portLabel, networks, driverNetwork, ports, networkStatus) returns an error — check port label not declared, address_mode 'driver' without DriverNetwork, etc.","commonSituations":"Check block with port = \"admin\" not present in network block; check-level address_mode = 'driver' on non-networked drivers; task running without network status yet (allocation not scheduled on a network).","solutions":["Correct the check's port to an existing network port label","Remove or fix the check-level address_mode (or inherit the service address by deleting check address fields)","Confirm the group network block declares the port and the allocation has a NetworkStatus","Inspect the wrapped %v detail to see whether it's a missing label vs unsupported mode"],"exampleFix":"// before\ncheck {\n  type = \"tcp\"\n  address_mode = \"driver\"\n}\n// after\ncheck {\n  type = \"tcp\"\n  address_mode = \"host\"\n  port = \"http\"\n}","handlingStrategy":"validation","validationCode":"// Check-level port label must resolve in the group network\nfor _, c := range svc.Checks {\n  if c.PortLabel != \"\" {\n    if _, ok := ports[c.PortLabel]; !ok {\n      return fmt.Errorf(\"check %q references undeclared port %q\", c.Name, c.PortLabel)\n    }\n  }\n  if c.AddressMode == \"driver\" {\n    return fmt.Errorf(\"check %q: driver address_mode requires a driver network\", c.Name)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only override check address/port when necessary — inherit the service's","Never use address_mode='driver' on drivers without network support","Validate jobs with `nomad job validate` before submission","Keep check port labels identical to declared network ports"],"tags":["consul","nomad","health-check","address-resolution"],"backgroundTag":"service-address-resolution-failed","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"}