{"record":{"id":"76289c74f5ac0c30","repo":"hashicorp/nomad","slug":"task-group-network-validation-failed-v","errorCode":null,"errorMessage":"Task group network validation failed: %v","messagePattern":"Task group network validation failed: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7294,"sourceCode":"\tif len(tg.Tasks) > 0 && mainTasks == 0 {\n\t\tmErr = multierror.Append(mErr, fmt.Errorf(\"Task group %s must have at least one main task\", tg.Name))\n\t}\n\n\t// Validate the volume requests\n\tvar canaries int\n\tif tg.Update != nil {\n\t\tcanaries = tg.Update.Canary\n\t}\n\tfor name, volReq := range tg.Volumes {\n\t\tif err := volReq.Validate(j.Type, tg.Count, canaries); err != nil {\n\t\t\tmErr = multierror.Append(mErr, fmt.Errorf(\n\t\t\t\t\"Task group volume validation for %s failed: %v\", name, err))\n\t\t}\n\t}\n\n\t// Validate task group and task network resources\n\tif err := tg.validateNetworks(); err != nil {\n\t\touter := fmt.Errorf(\"Task group network validation failed: %v\", err)\n\t\tmErr = multierror.Append(mErr, outer)\n\t}\n\n\t// Validate task group and task services\n\tif err := tg.validateServices(); err != nil {\n\t\touter := fmt.Errorf(\"Task group service validation failed: %v\", err)\n\t\tmErr = multierror.Append(mErr, outer)\n\t}\n\n\t// Validate group service script-checks\n\tif err := tg.validateScriptChecksInGroupServices(); err != nil {\n\t\touter := fmt.Errorf(\"Task group service check validation failed: %v\", err)\n\t\tmErr = multierror.Append(mErr, outer)\n\t}\n\n\t// Validate the scaling policy\n\tif err := tg.validateScalingPolicy(j); err != nil {\n\t\touter := fmt.Errorf(\"Task group scaling policy validation failed: %v\", err)","sourceCodeStart":7276,"sourceCodeEnd":7312,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7276-L7312","documentation":"TaskGroup.Validate calls tg.validateNetworks() and, if it fails, wraps the underlying error as \"Task group network validation failed: %v\" before appending it to the job multierror. It indicates invalid network resource configuration at the group or task level (e.g. conflicting port labels, illegal static/dynamic port mixes, bridge/hostname mode constraints).","triggerScenarios":"Submitting a job whose `network` stanza (group-level or legacy task-level) fails inner validation — duplicate port labels, reserved ports out of range, network mode unsupported, hostname collisions across tasks.","commonSituations":"Two tasks in a group declaring the same port label; static port conflicts between groups; using `mode = \"bridge\"` on clients without CNI; copying old task-level network stanzas into groups.","solutions":["Inspect the wrapped inner error and correct the offending network/port field in the group.","Ensure port labels are unique within the group and static ports are within the client's allowed range.","Verify the target client supports the requested network mode (bridge/cni plugin installed)."],"exampleFix":"// before\nnetwork {\n  port \"http\" { static = 8080 }\n  port \"http\" { to = 8081 }\n}\n// after\nnetwork {\n  port \"http\" { to = 8080 }\n  port \"metrics\" { to = 8081 }\n}","handlingStrategy":"validation","validationCode":"// Go: check for duplicate port labels in group networks\nlabels := map[string]bool{}\nfor _, n := range tg.Networks {\n  for _, p := range n.DynamicPorts {\n    if labels[p.Label] {\n      return fmt.Errorf(\"duplicate port label %q\", p.Label)\n    }\n    labels[p.Label] = true\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer group-level network stanzas (task-level ones are legacy).","Confirm CNI plugins are installed on clients for mode = \"bridge\".","Reserve static ports centrally to avoid cross-group conflicts."],"tags":["nomad","job-validation","network","ports"],"backgroundTag":"nomad-job-validation-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"}