hashicorp/nomad · error

Check %s invalid: refers to non-existent task %s

Error message

Check %s invalid: refers to non-existent task %s

What it means

Service check validation error: the check's task-level reference (e.g. a Consul check task name) points at a task that does not exist in the job's task group, so Nomad cannot resolve where to run the check.

Source

Thrown at nomad/structs/structs.go:7549

			outer := fmt.Errorf("Service[%d] %s validation failed: %s", i, service.Name, err)
			mErr.Errors = append(mErr.Errors, outer)
			// we break here to avoid the risk of crashing on null-pointer
			// access in a later step, accepting that we might miss out on
			// error messages to provide the user.
			continue
		}
		if service.AddressMode == AddressModeDriver {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("service %q cannot use address_mode=\"driver\", only services defined in a \"task\" block can use this mode", service.Name))
		}

		for _, check := range service.Checks {
			if check.TaskName != "" {
				if check.AddressMode == AddressModeDriver {
					mErr.Errors = append(mErr.Errors, fmt.Errorf("Check %q invalid: cannot use address_mode=\"driver\", only checks defined in a \"task\" service block can use this mode", service.Name))
				}
				if !taskSet.Contains(check.TaskName) {
					mErr.Errors = append(mErr.Errors,
						fmt.Errorf("Check %s invalid: refers to non-existent task %s", check.Name, check.TaskName))
				}
			}
		}
	}

	// Produce an error of any services which are not unique enough in the group
	// i.e. have same <task, name, port>
	if idDuplicateSet.Size() > 0 {
		mErr.Errors = append(mErr.Errors,
			fmt.Errorf(
				"Services are not unique: %s",
				idDuplicateSet.StringFunc(
					func(u unique) string {
						s := u.task + "->" + u.name
						if u.port != "" {
							s += ":" + u.port
						}
						return s

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Correct the check's task name to match an existing task in the same group.
  2. Remove the task field if the check should target the service's own task.
  3. Re-add or rename the referenced task if it was removed by mistake.

Example fix

// before
check "c" { task="wev" }
// after
check "c" { task="web" }
Defensive patterns

Strategy: validation

Validate before calling

tasks := map[string]bool{"web":true,"api":true}
for _, c := range svc.Checks {
  if c.TaskName != "" && !tasks[c.TaskName] {
    return fmt.Errorf("check %q: unknown task %q", c.Name, c.TaskName)
  }
}

Prevention

When it happens

Trigger: A check specifies task = "foo" while the group defines no task named 'foo' (typo, removed task, or task defined in a different group); surfaced during group validation.

Common situations: Renaming or deleting a task without updating checks that reference it; typos in the task name; cross-group references, which Nomad does not allow.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/2991e8830098a362. Report an issue: GitHub.