hashicorp/nomad · error

socket path %s is longer than the maximum length allowed (%d

Error message

socket path %s is longer than the maximum length allowed (%d), try to reduce the task name or Nomad's data_dir if possible.

What it means

validateSocketPath enforces the platform's Unix domain socket path length limit (maxSocketPathLen, e.g. 108 on Linux) because the QEMU monitor socket lives under the Nomad data_dir keyed by task name. Overly long paths would silently fail at bind time, so it is rejected up front.

Source

Thrown at drivers/qemu/driver.go:862

		result = &drivers.ExitResult{
			ExitCode:  ps.ExitCode,
			Signal:    ps.Signal,
			OOMKilled: ps.OOMKilled,
		}
	}

	select {
	case <-ctx.Done():
	case <-d.ctx.Done():
	case ch <- result:
	}
}

// validateSocketPath provides best effort validation of socket paths since
// some rules may be platform-dependant.
func validateSocketPath(path string) error {
	if maxSocketPathLen > 0 && len(path) > maxSocketPathLen {
		return fmt.Errorf(
			"socket path %s is longer than the maximum length allowed (%d), try to reduce the task name or Nomad's data_dir if possible.",
			path, maxSocketPathLen)
	}

	return nil
}

// sendQemuShutdown attempts to issue an ACPI power-off command via the qemu
// monitor
func sendQemuShutdown(logger hclog.Logger, monitorPath string, userPid int) error {
	if monitorPath == "" {
		return errors.New("monitorPath not set")
	}
	monitorSocket, err := net.Dial("unix", monitorPath)
	if err != nil {
		logger.Warn("could not connect to qemu monitor", "pid", userPid, "monitorPath", monitorPath, "error", err)
		return err
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Shorten the task name in the job spec
  2. Move Nomad's data_dir to a shorter top-level path (e.g. /opt/nomaddata)
  3. Reduce directory nesting that inflates the path length
  4. The error message itself suggests both remedies — reduce task name or data_dir length

Example fix

// before
name = "my-very-long-qemu-virtual-machine-task-name-for-batch-1234567890"
data_dir = "/var/lib/very/long/nested/nomad/client/data/directory/path"
// after
name = "qemu-vm-1"
data_dir = "/opt/nomad/data"
Defensive patterns

Strategy: validation

Validate before calling

const maxSocketPathLen = 108 // Linux sun_path limit
socketPath := filepath.Join(dataDir, "alloc", allocID, "qemu", taskName, "monitor.sock")
if len(socketPath) > maxSocketPathLen {
    return fmt.Errorf("socket path too long (%d > %d): shorten task name or data_dir", len(socketPath), maxSocketPathLen)
}

Prevention

When it happens

Trigger: StartTask when the computed monitor/QMP socket path — derived from data_dir + alloc ID + task name — exceeds maxSocketPathLen characters.

Common situations: Long task names or long allocation IDs combined with a deeply nested data_dir (e.g. inside long CI workspace paths); running Nomad from a very long directory.

Related errors


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