{"record":{"id":"55f37afb3ea295fb","repo":"hashicorp/nomad","slug":"failed-creating-temporary-directory-for-the-allocd","errorCode":null,"errorMessage":"failed creating temporary directory for the AllocDir: %v","messagePattern":"failed creating temporary directory for the AllocDir: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"client/client.go","lineNumber":749,"sourceCode":"\t}\n\n\t// Ensure the alloc mounts dir exists if we are configured with a custom path.\n\tif conf.AllocMountsDir != \"\" {\n\t\tif err := os.MkdirAll(conf.AllocMountsDir, 0o711); err != nil {\n\t\t\treturn fmt.Errorf(\"failed creating alloc mounts dir: %w\", err)\n\t\t}\n\t}\n\n\t// Ensure the alloc dir exists if we are configured with a custom path.\n\tif conf.AllocDir != \"\" {\n\t\tif err := os.MkdirAll(conf.AllocDir, 0o711); err != nil {\n\t\t\treturn fmt.Errorf(\"failed creating alloc dir: %w\", err)\n\t\t}\n\t} else {\n\t\t// Otherwise make a temp directory to use.\n\t\tp, err := os.MkdirTemp(\"\", \"NomadClient\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed creating temporary directory for the AllocDir: %v\", err)\n\t\t}\n\n\t\tp, err = filepath.EvalSymlinks(p)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to find temporary directory for the AllocDir: %v\", err)\n\t\t}\n\n\t\t// Change the permissions to have the execute bit\n\t\tif err := os.Chmod(p, 0o711); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to change directory permissions for the AllocDir: %v\", err)\n\t\t}\n\n\t\tconf = c.UpdateConfig(func(c *config.Config) {\n\t\t\tc.AllocDir = p\n\t\t\tc.AllocMountsDir = p\n\t\t})\n\t}\n","sourceCodeStart":731,"sourceCodeEnd":767,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/client.go#L731-L767","documentation":"When no custom alloc_dir is configured, the client creates a temporary directory with os.MkdirTemp(\"\", \"NomadClient\") during init. If this OS call fails, startup aborts with this error. It means the system temp root itself is unusable.","triggerScenarios":"client init without alloc_dir configured: os.MkdirTemp(\"\", \"NomadClient\") returns error (typically because TMPDIR//tmp is missing, unwritable, or the disk is full).","commonSituations":"Containers with no /tmp, TMPDIR pointing to a non-existent path, full tmpfs (/tmp mounted with small size), or restrictive permissions on the temp root.","solutions":["Ensure TMPDIR (or /tmp) exists, is writable by the nomad user, and has free space: ls -ld \"$TMPDIR\" && df -h \"$TMPDIR\".","Fix or unset a bad TMPDIR environment variable for the Nomad service (e.g. in the systemd unit).","Configure an explicit alloc_dir so the temp directory path is never used."],"exampleFix":"// before (systemd unit)\nEnvironment=TMPDIR=/var/tmp/nomad  # directory missing\n// after\nExecStartPre=/usr/bin/mkdir -p /var/tmp/nomad\nEnvironment=TMPDIR=/var/tmp/nomad\n# or set client { alloc_dir = \"/var/lib/nomad/alloc\" }","handlingStrategy":"validation","validationCode":"tmp := os.TempDir()\nif fi, err := os.Stat(tmp); err != nil || !fi.IsDir() {\n    return fmt.Errorf(\"TMPDIR %q invalid: %v\", tmp, err)\n}\nprobe, err := os.MkdirTemp(tmp, \"NomadClientProbe\")\nif err != nil {\n    return fmt.Errorf(\"cannot create temp dir: %v\", err)\n}\nos.Remove(probe)","typeGuard":null,"tryCatchPattern":"if err := clientInit(); err != nil {\n    if strings.Contains(err.Error(), \"failed creating temporary directory for the AllocDir\") {\n        // fix TMPDIR or set explicit alloc_dir, then restart\n    }\n}","preventionTips":["Ensure /tmp (or TMPDIR) exists and is writable by the nomad service user","Avoid undersized tmpfs mounts for the temp root","Fix or remove bogus TMPDIR entries in systemd units","Prefer an explicit alloc_dir on production nodes"],"tags":["client-init","temp-directory","filesystem","tmpdir"],"backgroundTag":"temp-dir-creation-failed","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"}