hashicorp/nomad · error

job %q doesn't exist or it has no allocations

Error message

job %q doesn't exist or it has no allocations

What it means

Validation outcome in getRandomJobAlloc: the API returned the job's allocation list successfully but it is empty, meaning the job exists yet has no allocations (never scheduled, or all stopped); the command cannot pick an allocation.

Source

Thrown at command/alloc_fs.go:388

	return r, nil
}

// Get Random Allocation from a known jobID. Prefer to use a running allocation,
// but use a dead allocation if no running allocations are found
func getRandomJobAlloc(client *api.Client, jobID, taskGroupName, namespace string) (*api.AllocationListStub, error) {
	var runningAllocs []*api.AllocationListStub
	q := &api.QueryOptions{
		Namespace: namespace,
	}

	allocs, _, err := client.Jobs().Allocations(jobID, false, q)
	if err != nil {
		return nil, fmt.Errorf("error querying job %q: %w", jobID, err)
	}

	// Check that the job actually has allocations
	if len(allocs) == 0 {
		return nil, fmt.Errorf("job %q doesn't exist or it has no allocations", jobID)
	}

	if taskGroupName != "" {
		var filteredAllocs []*api.AllocationListStub
		for _, alloc := range allocs {
			if alloc.TaskGroup == taskGroupName {
				filteredAllocs = append(filteredAllocs, alloc)
			}
		}
		allocs = filteredAllocs
		if len(allocs) == 0 {
			return nil, fmt.Errorf("task group %q doesn't exist or it has no allocations", taskGroupName)
		}
	}

	for _, v := range allocs {
		if v.ClientStatus == "running" {
			runningAllocs = append(runningAllocs, v)

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Run nomad job status <job> to see why the job has no allocations
  2. Start the job or wait for scheduling to place at least one allocation
  3. Specify a different job that currently has allocations
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at command/alloc_fs.go:388 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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