{"record":{"id":"90dc1c4ecc51bbb9","repo":"hashicorp/nomad","slug":"s-checks-require-an-address","errorCode":null,"errorMessage":"%s checks require an address","messagePattern":"(.+?) checks require an address","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/consul/service_client.go","lineNumber":2016,"sourceCode":"// Script checks simply have a TTL set and the caller is responsible for\n// running the script and heart-beating.\nfunc createCheckReg(serviceID, checkID string, check *structs.ServiceCheck, host string, port int, namespace string) (*api.AgentCheckRegistration, error) {\n\tchkReg := api.AgentCheckRegistration{\n\t\tID:        checkID,\n\t\tName:      check.Name,\n\t\tServiceID: serviceID,\n\t\tNamespace: normalizeNamespace(namespace),\n\t}\n\tchkReg.Status = check.InitialStatus\n\tchkReg.Timeout = check.Timeout.String()\n\tchkReg.Interval = check.Interval.String()\n\tchkReg.SuccessBeforePassing = check.SuccessBeforePassing\n\tchkReg.FailuresBeforeCritical = check.FailuresBeforeCritical\n\tchkReg.FailuresBeforeWarning = check.FailuresBeforeWarning\n\n\t// Require an address for http or tcp checks\n\tif port == 0 && check.RequiresPort() {\n\t\treturn nil, fmt.Errorf(\"%s checks require an address\", check.Type)\n\t}\n\n\tswitch check.Type {\n\tcase structs.ServiceCheckHTTP:\n\t\tproto := check.Protocol\n\t\tif proto == \"\" {\n\t\t\tproto = \"http\"\n\t\t}\n\t\tif check.TLSSkipVerify {\n\t\t\tchkReg.TLSSkipVerify = true\n\t\t}\n\t\tchkReg.TLSServerName = check.TLSServerName\n\t\tbase := url.URL{\n\t\t\tScheme: proto,\n\t\t\tHost:   net.JoinHostPort(host, strconv.Itoa(port)),\n\t\t}\n\t\trelative, err := url.Parse(check.Path)\n\t\tif err != nil {","sourceCodeStart":1998,"sourceCodeEnd":2034,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/consul/service_client.go#L1998-L2034","documentation":"When converting a Nomad service check definition into a Consul agent check registration, HTTP/TCP-style checks need a concrete address:port target. If the check requires a port but the resolved service address has port 0 (no address), registration cannot proceed and Nomad refuses to build the check.","triggerScenarios":"Registering a service check of type http, tcp, or grpc (check.RequiresPort() true) where the check block has neither a port_label nor address_mode-resolvable port, so port == 0 when building the api.AgentServiceCheck.","commonSituations":"Service stanza declares a check but no port in the service block; address_mode=\"driver\" with a task driver that exposes no ports; typo in port label so no port resolves.","solutions":["Add a port or port label to the service stanza so the check has a target address.","Set the check's address/port explicitly via check block port or address_mode=\"host\" with a host port.","If the check is script-based, switch its type so it does not require a port."],"exampleFix":"// before\nservice { name = \"web\" check { type = \"http\", path = \"/health\" } }\n// after\nservice { name = \"web\", port = \"http\"\n  check { type = \"http\", path = \"/health\", interval = \"10s\", timeout = \"2s\" } }","handlingStrategy":"validation","validationCode":"// hcl pre-check\n// a check with type http|tcp|grpc must have a resolvable port\nservice {\n  name = \"web\"\n  port = \"http\"          # must resolve to > 0\n  check { type = \"http\", path = \"/health\", interval = \"10s\", timeout = \"2s\" }\n}\n# validate with: nomad job validate job.nomad.hcl","typeGuard":"func checkHasPort(svc api.ServiceCheck) bool {\n  return !svc.RequiresPort() || svc.PortLabel != \"\"\n}","tryCatchPattern":"try {\n  nomad.jobRegister(job)\n} catch err {\n  if strings.Contains(err.Error(), \"require an address\") {\n    log.Error(\"check missing port label\", \"service\", err)\n  }\n}","preventionTips":["Always set a port or port_label on services that define http/tcp/grpc checks.","Run `nomad job validate` in CI before submitting jobs.","Prefer address_mode=\"host\" when drivers expose no ports.","Check that interpolated port labels actually exist in the task's network block."],"tags":["consul","service-check","configuration"],"backgroundTag":"missing-check-address","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"}