{"record":{"id":"ea8296c009b74aba","repo":"hashicorp/nomad","slug":"setting-up-server-node-id-failed-s","errorCode":null,"errorMessage":"setting up server node ID failed: %s","messagePattern":"setting up server node ID failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"command/agent/agent.go","lineNumber":1190,"sourceCode":"\treturn conf, nil\n}\n\n// setupServer is used to setup the server if enabled\nfunc (a *Agent) setupServer() error {\n\tif !a.config.Server.Enabled {\n\t\treturn nil\n\t}\n\n\t// Setup the configuration\n\tconf, err := a.serverConfig()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"server config setup failed: %s\", err)\n\t}\n\n\t// Generate a node ID and persist it if it is the first instance, otherwise\n\t// read the persisted node ID.\n\tif err := a.setupNodeID(conf); err != nil {\n\t\treturn fmt.Errorf(\"setting up server node ID failed: %s\", err)\n\t}\n\n\t// Sets up the keyring for gossip encryption\n\tif err := a.setupKeyrings(conf); err != nil {\n\t\treturn fmt.Errorf(\"failed to configure keyring: %v\", err)\n\t}\n\n\t// Create the server\n\tserver, err := nomad.NewServer(conf,\n\t\ta.consulCatalog,           // self service discovery\n\t\ta.consulConfigEntriesFunc, // writing config entries for gateways\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"server setup failed: %v\", err)\n\t}\n\ta.server = server\n\n\t// Consul check addresses default to bind but can be toggled to use advertise","sourceCodeStart":1172,"sourceCodeEnd":1208,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/agent.go#L1172-L1208","documentation":"After building the server config, setupServer calls setupNodeID to generate or read the persisted node ID. Failure here (usually filesystem errors on the node ID file) is wrapped as this error and NewAgent aborts.","triggerScenarios":"setupNodeID fails while creating or reading <data_dir>/server/node_id: unwritable data_dir, node_id file with bad permissions/corruption, or provided node_id conflicting with persisted state.","commonSituations":"Disk full or read-only filesystem on /var/lib/nomad, running the agent as a different user than the one owning data_dir, restoring data_dir snapshots with wrong ownership, or manual node_id edits.","solutions":["Check data_dir/server is writable by the Nomad process user","Fix ownership/permissions of the node_id file (chown/chmod) or remove it to regenerate","Verify disk space and that the filesystem is not mounted read-only","If node_id was manually set in config, ensure it is a valid UUID and consistent with the persisted file"],"exampleFix":"// before (shell)\nls -l /var/lib/nomad/server/node_id  # owned by root, nomad cannot read\n// after (shell)\nchown nomad:nomad /var/lib/nomad/server/node_id && chmod 600 /var/lib/nomad/server/node_id","handlingStrategy":"validation","validationCode":"nodeIDPath := filepath.Join(dataDir, \"server\", \"node_id\")\nif f, err := os.OpenFile(nodeIDPath, os.O_RDWR, 0600); err != nil {\n    log.Fatalf(\"cannot access node ID file %s: %v\", nodeIDPath, err)\n} else {\n    f.Close()\n}","typeGuard":null,"tryCatchPattern":"if err := setupNodeID(conf); err != nil {\n    return fmt.Errorf(\"setting up server node ID failed: %w\", err)\n}","preventionTips":["Run the agent under a consistent user with ownership of data_dir","Monitor disk space and avoid read-only remounts on data_dir volumes","Never hand-edit or copy node_id between servers","Restore data_dir snapshots with correct ownership/permissions"],"tags":["nomad","server","node-id","filesystem"],"backgroundTag":"node-id-setup-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"}