hashicorp/nomad · error

Error querying job: %s

Error message

Error querying job: %s

What it means

Raised by outputPeriodicInfo in `nomad job status` when the API call Jobs().PrefixList(prefix) — which lists child jobs launched by a periodic job, using the <job-id><JobPeriodicLaunchSuffix> prefix — fails. The raw client error (connection, ACL, server error) is interpolated with %s and reported as a job-query failure.

Source

Thrown at command/job_status.go:350

		c.Ui.Warn(hint)
	}

	return 0
}

// outputPeriodicInfo prints information about the passed periodic job. If a
// request fails, an error is returned.
func (c *JobStatusCommand) outputPeriodicInfo(client *api.Client, job *api.Job) error {
	// Output the summary
	if err := c.outputJobSummary(client, job); err != nil {
		return err
	}

	// Generate the prefix that matches launched jobs from the periodic job.
	prefix := fmt.Sprintf("%s%s", *job.ID, api.JobPeriodicLaunchSuffix)
	children, _, err := client.Jobs().PrefixList(prefix)
	if err != nil {
		return fmt.Errorf("Error querying job: %s", err)
	}

	if len(children) == 0 {
		c.Ui.Output("\nNo instances of periodic job found")
		return nil
	}

	out := make([]string, 1)
	out[0] = "ID|Status"
	for _, child := range children {
		// Ensure that we are only showing jobs whose parent is the requested
		// job.
		if child.ParentID != *job.ID {
			continue
		}

		out = append(out, fmt.Sprintf("%s|%s",
			child.ID,

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Check the interpolated cause: fix connectivity (curl $NOMAD_ADDR/v1/agent/health) or restart the Nomad agent.
  2. Pass the correct -namespace/-region or set NOMAD_NAMESPACE/NOMAD_REGION so the prefix list targets the right scope.
  3. Verify the ACL token can list jobs in the namespace (namespace = list-jobs); refresh with nomad acl token self or request a scoped token.
  4. Retry if the server returned a transient 5xx (raft leadership change).

Example fix

// before
nomad job status periodic-backup   // Error querying job: permission denied
// after
NOMAD_NAMESPACE=prod nomad acl token self     # confirm scope
NOMAD_NAMESPACE=prod nomad job status periodic-backup
Defensive patterns

Strategy: retry

Validate before calling

// confirm agent reachability and token scope first
curl -sf -H "X-Nomad-Token: $NOMAD_TOKEN" "$NOMAD_ADDR/v1/jobs?namespace=$NOMAD_NAMESPACE" > /dev/null

Try / catch

children, _, err := client.Jobs().PrefixList(prefix)
if err != nil {
    if strings.Contains(err.Error(), "permission denied") {
        // fix ACL token, do not retry
    } else {
        // transient: retry with backoff
    }
    return err
}

Prevention

When it happens

Trigger: client.Jobs().PrefixList(prefix) returns an error while listing periodic job instances: agent unreachable, ACL token lacking job read in the namespace, wrong namespace/region query options, or server-side 5xx.

Common situations: Running nomad job status with a read-only or expired token against a namespace-restricted cluster; NOMAD_ADDR pointing at a down agent; periodic job inspected across namespace boundary without -namespace flag.

Related errors


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