hashicorp/nomad · error

error following logs: %s

Error message

error following logs: %s

What it means

Raised after the log reader is successfully opened, when io.Copy(os.Stdout, r) fails while streaming log contents to the terminal - the stream broke mid-read (client disconnect, allocation stopped, network error).

Source

Thrown at command/alloc_logs.go:310

		} else {
			l.numLines = defaultTailLines
		}

		r, readErr = l.followFile(client, alloc, logType, api.OriginEnd, offset)

		// If numLines is set, wrap the reader
		if l.numLines != -1 {
			r = NewLineLimitReader(r, int(l.numLines), int(l.numLines*bytesToLines), 1*time.Second)
		}

		if readErr != nil {
			return fmt.Errorf("error tailing file: %v", readErr)
		}
	}

	defer r.Close()
	if _, err := io.Copy(os.Stdout, r); err != nil {
		return fmt.Errorf("error following logs: %s", err)
	}

	return nil
}

// followFile outputs the contents of the file to stdout relative to the end of
// the file.
func (l *AllocLogsCommand) followFile(client *api.Client, alloc *api.Allocation,
	logType, origin string, offset int64) (io.ReadCloser, error) {

	cancel := make(chan struct{})
	frames, errCh := client.AllocFS().Logs(alloc, l.follow, l.task, logType, origin, offset, cancel, nil)

	// Setting up the logs stream can fail, therefore we need to check the
	// error channel before continuing further.
	select {
	case err := <-errCh:
		return nil, err

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Check network stability between CLI and the Nomad client
  2. Confirm the allocation/task did not stop during streaming
  3. Re-run the command to restart the log stream
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at command/alloc_logs.go:310 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/5e6ce6324be71422. Report an issue: GitHub.