{"record":{"id":"3a2d55a152e5ad4d","repo":"hashicorp/nomad","slug":"failed-to-write-peers-info-file-v","errorCode":null,"errorMessage":"failed to write peers.info file: %v","messagePattern":"failed to write peers\\.info file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/server.go","lineNumber":1537,"sourceCode":"\t\t\tif s.raftStore != nil {\n\t\t\t\ts.raftStore.Close()\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tsnap = snapshots\n\n\t\t// For an existing cluster being upgraded to the new version of\n\t\t// Raft, we almost never want to run recovery based on the old\n\t\t// peers.json file. We create a peers.info file with a helpful\n\t\t// note about where peers.json went, and use that as a sentinel\n\t\t// to avoid ingesting the old one that first time (if we have to\n\t\t// create the peers.info file because it's not there, we also\n\t\t// blow away any existing peers.json file).\n\t\tpeersFile := filepath.Join(path, \"peers.json\")\n\t\tpeersInfoFile := filepath.Join(path, \"peers.info\")\n\t\tif _, err := os.Stat(peersInfoFile); os.IsNotExist(err) {\n\t\t\tif err := os.WriteFile(peersInfoFile, []byte(peersInfoContent), 0644); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to write peers.info file: %v\", err)\n\t\t\t}\n\n\t\t\t// Blow away the peers.json file if present, since the\n\t\t\t// peers.info sentinel wasn't there.\n\t\t\tif _, err := os.Stat(peersFile); err == nil {\n\t\t\t\tif err := os.Remove(peersFile); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to delete peers.json, please delete manually (see peers.info for details): %v\", err)\n\t\t\t\t}\n\t\t\t\ts.logger.Info(\"deleted peers.json file (see peers.info for details)\")\n\t\t\t}\n\t\t} else if _, err := os.Stat(peersFile); err == nil {\n\t\t\ts.logger.Info(\"found peers.json file, recovering Raft configuration...\")\n\t\t\tvar configuration raft.Configuration\n\t\t\tif s.config.RaftConfig.ProtocolVersion < 3 {\n\t\t\t\tconfiguration, err = raft.ReadPeersJSON(peersFile)\n\t\t\t} else {\n\t\t\t\tconfiguration, err = raft.ReadConfigJSON(peersFile)\n\t\t\t}","sourceCodeStart":1519,"sourceCodeEnd":1555,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/server.go#L1519-L1555","documentation":"During Raft store initialization the server could not write the peers.info sentinel file under the data directory; this wraps the filesystem error, typically caused by permissions, a full disk, or an invalid path.","triggerScenarios":"setupRaft(): peers.info does not exist and os.WriteFile(peersInfoFile, peersInfoContent, 0644) fails while initializing <data_dir>/raft.","commonSituations":"data_dir permissions wrong; read-only filesystem; disk full; data_dir path misconfigured to a non-writable location.","solutions":["Check data_dir exists and is writable by the Nomad user","Free disk space or fix the filesystem error reported by the OS","Retry starting the server once the underlying IO problem is resolved"],"exampleFix":"# before: read-only raft dir\n# after\n$ sudo chown -R nomad:nomad /var/lib/nomad/raft\n$ sudo systemctl restart nomad","handlingStrategy":"fallback","validationCode":"rf := filepath.Join(dataDir, \"raft\")\nprobe := filepath.Join(rf, \".probe\")\nif err := os.WriteFile(probe, []byte(\"x\"), 0644); err != nil {\n    return fmt.Errorf(\"raft dir not writable: %w\", err)\n}\nos.Remove(probe)","typeGuard":null,"tryCatchPattern":"if err := server.Start(); err != nil {\n    if strings.Contains(err.Error(), \"failed to write peers.info file\") {\n        logger.Error(\"check raft dir permissions/disk space\")\n    }\n    return err\n}","preventionTips":["Ensure the nomad user owns data_dir recursively","Keep data_dir off read-only or full filesystems","Verify writability in pre-start health checks"],"tags":["filesystem","raft","storage","nomad"],"backgroundTag":"file-write-permission-denied","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"}