{"record":{"id":"9dfeb7bdbd7df86b","repo":"hashicorp/nomad","slug":"socket-path-s-is-longer-than-the-maximum-length-a","errorCode":null,"errorMessage":"socket path %s is longer than the maximum length allowed (%d), try to reduce the task name or Nomad's data_dir if possible.","messagePattern":"socket path (.+?) is longer than the maximum length allowed \\((.+?)\\), try to reduce the task name or Nomad's data_dir if possible\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/qemu/driver.go","lineNumber":862,"sourceCode":"\t\tresult = &drivers.ExitResult{\n\t\t\tExitCode:  ps.ExitCode,\n\t\t\tSignal:    ps.Signal,\n\t\t\tOOMKilled: ps.OOMKilled,\n\t\t}\n\t}\n\n\tselect {\n\tcase <-ctx.Done():\n\tcase <-d.ctx.Done():\n\tcase ch <- result:\n\t}\n}\n\n// validateSocketPath provides best effort validation of socket paths since\n// some rules may be platform-dependant.\nfunc validateSocketPath(path string) error {\n\tif maxSocketPathLen > 0 && len(path) > maxSocketPathLen {\n\t\treturn fmt.Errorf(\n\t\t\t\"socket path %s is longer than the maximum length allowed (%d), try to reduce the task name or Nomad's data_dir if possible.\",\n\t\t\tpath, maxSocketPathLen)\n\t}\n\n\treturn nil\n}\n\n// sendQemuShutdown attempts to issue an ACPI power-off command via the qemu\n// monitor\nfunc sendQemuShutdown(logger hclog.Logger, monitorPath string, userPid int) error {\n\tif monitorPath == \"\" {\n\t\treturn errors.New(\"monitorPath not set\")\n\t}\n\tmonitorSocket, err := net.Dial(\"unix\", monitorPath)\n\tif err != nil {\n\t\tlogger.Warn(\"could not connect to qemu monitor\", \"pid\", userPid, \"monitorPath\", monitorPath, \"error\", err)\n\t\treturn err\n\t}","sourceCodeStart":844,"sourceCodeEnd":880,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/qemu/driver.go#L844-L880","documentation":"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.","triggerScenarios":"StartTask when the computed monitor/QMP socket path — derived from data_dir + alloc ID + task name — exceeds maxSocketPathLen characters.","commonSituations":"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.","solutions":["Shorten the task name in the job spec","Move Nomad's data_dir to a shorter top-level path (e.g. /opt/nomaddata)","Reduce directory nesting that inflates the path length","The error message itself suggests both remedies — reduce task name or data_dir length"],"exampleFix":"// before\nname = \"my-very-long-qemu-virtual-machine-task-name-for-batch-1234567890\"\ndata_dir = \"/var/lib/very/long/nested/nomad/client/data/directory/path\"\n// after\nname = \"qemu-vm-1\"\ndata_dir = \"/opt/nomad/data\"","handlingStrategy":"validation","validationCode":"const maxSocketPathLen = 108 // Linux sun_path limit\nsocketPath := filepath.Join(dataDir, \"alloc\", allocID, \"qemu\", taskName, \"monitor.sock\")\nif len(socketPath) > maxSocketPathLen {\n    return fmt.Errorf(\"socket path too long (%d > %d): shorten task name or data_dir\", len(socketPath), maxSocketPathLen)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep task names short","Place Nomad data_dir near filesystem root","Pre-compute socket path lengths in provisioning scripts"],"tags":["qemu","socket","path-length","unix-socket","nomad-driver"],"backgroundTag":"path-too-long","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}