hashicorp/nomad · error

Error querying job allocations: %s

Error message

Error querying job allocations: %s

What it means

Raised by outputJobInfo in `nomad job status` when Jobs().Allocations(jobID, all, q) fails to fetch the job's allocation list. The client error (network, ACL, namespace, server) is wrapped into this message and shown instead of the allocation table. Note the query also fails when the job ID doesn't resolve in the selected namespace.

Source

Thrown at command/job_status.go:435

	}

	c.Ui.Output(c.Colorize().Color("\n[bold]Dispatched Jobs[reset]"))
	c.Ui.Output(formatList(out))
	return nil
}

// outputJobInfo prints information about the passed non-periodic job. If a
// request fails, an error is returned.
func (c *JobStatusCommand) outputJobInfo(client *api.Client, job *api.Job) error {
	var q *api.QueryOptions
	if job.Namespace != nil {
		q = &api.QueryOptions{Namespace: *job.Namespace}
	}

	// Query the allocations
	jobAllocs, _, err := client.Jobs().Allocations(*job.ID, c.allAllocs, q)
	if err != nil {
		return fmt.Errorf("Error querying job allocations: %s", err)
	}

	// Query the evaluations
	jobEvals, _, err := client.Jobs().Evaluations(*job.ID, q)
	if err != nil {
		return fmt.Errorf("Error querying job evaluations: %s", err)
	}

	latestDeployment, _, err := client.Jobs().LatestDeployment(*job.ID, q)
	if err != nil {
		return fmt.Errorf("Error querying latest job deployment: %s", err)
	}

	jobActions := make([]map[string]string, 0)
	for _, tg := range job.TaskGroups {
		for _, task := range tg.Tasks {
			for _, action := range task.Actions {
				jobActions = append(jobActions, map[string]string{

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Fix the underlying cause shown after the colon (connection refused/DNS, permission denied, 5xx).
  2. Set the correct namespace/region: nomad job status -namespace <ns> -region <r> <job>.
  3. Validate ACLs: the token needs list-jobs and read-alloc permissions in the target namespace.
  4. Retry after transient server errors (leader election) or restore agent connectivity.

Example fix

// before
curl -s $NOMAD_ADDR/v1/job/web/allocations   # 403 permission denied
// after
export NOMAD_TOKEN=<token-with-alloc-read>
nomad job status -namespace default web
Defensive patterns

Strategy: try-catch

Validate before calling

# pre-flight: can this token list allocations in the namespace?
curl -sf -H "X-Nomad-Token: $NOMAD_TOKEN" \
  "$NOMAD_ADDR/v1/job/$JOB_ID/allocations?namespace=$NOMAD_NAMESPACE" > /dev/null

Type guard

func isPermDenied(err error) bool {
    return err != nil && strings.Contains(err.Error(), "permission denied")
}

Try / catch

jobAllocs, _, err := client.Jobs().Allocations(id, all, q)
if err != nil {
    switch {
    case isPermDenied(err):
        return fmt.Errorf("token lacks allocation read in %s", ns)
    default:
        return retryWithBackoff(...)
    }
}

Prevention

When it happens

Trigger: client.Jobs().Allocations(*job.ID, c.allAllocs, q) returns an error: agent unreachable, ACL token missing allocation-list permission in the namespace, wrong -namespace/-region, or server 5xx during the read.

Common situations: Token restricted to other namespaces; listing allocations for a job in the default namespace when it exists elsewhere; network interruption or agent restart while running status; stale NOMAD_ADDR after cluster migration.

Related errors


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