hashicorp/nomad · error · ErrTaskNotRunning

Task not running

Error message

Task not running

What it means

Sentinel ErrTaskNotRunning: returned when an operation (e.g. exec, kill, signal) targets a task that is not in the running state. Defined in the taskrunner errors package to avoid import cycles; callers like alloc_runner treat it as benign when stopping tasks.

Source

Thrown at client/allocrunner/taskrunner/errors/errors.go:14

// Copyright IBM Corp. 2015, 2026
// SPDX-License-Identifier: BUSL-1.1

package errors

import (
	"errors"

	"github.com/hashicorp/nomad/nomad/structs"
)

// ErrTaskNotRunning is returned when the underlying task is not currently
// running. It's defined here to avoid import cycles.
var ErrTaskNotRunning = errors.New("Task not running")

// NewHookError contains an underlying err and a pre-formatted task event.
func NewHookError(err error, taskEvent *structs.TaskEvent) error {
	return &HookError{
		Err:       err,
		TaskEvent: taskEvent,
	}
}

type HookError struct {
	TaskEvent *structs.TaskEvent
	Err       error
}

func (h *HookError) Error() string {
	return h.Err.Error()
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Wait for the task to reach 'running' before issuing exec/signal operations
  2. Treat it as a no-op when the intent was to stop or kill the task
  3. Check task logs/events for why the task exited
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at client/allocrunner/taskrunner/errors/errors.go:14 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/eed8d2d40c0dc05c. Report an issue: GitHub.