{"record":{"id":"e4c2eaf0c904a694","repo":"nats-io/nats-server","slug":"storage-directory-is-not-writable","errorCode":null,"errorMessage":"storage directory is not writable","messagePattern":"storage directory is not writable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/filestore.go","lineNumber":447,"sourceCode":"\tif fcfg.SubjectStateExpire == 0 {\n\t\tfcfg.SubjectStateExpire = defaultFssExpiration\n\t}\n\tif fcfg.SyncInterval == 0 {\n\t\tfcfg.SyncInterval = defaultSyncInterval\n\t}\n\tdios := fcfg.srv.diskIOSemaphore()\n\n\t// Check the directory\n\tif stat, err := os.Stat(fcfg.StoreDir); os.IsNotExist(err) {\n\t\tif err := os.MkdirAll(fcfg.StoreDir, defaultDirPerms); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"could not create storage directory - %v\", err)\n\t\t}\n\t} else if stat == nil || !stat.IsDir() {\n\t\treturn nil, fmt.Errorf(\"storage directory is not a directory\")\n\t}\n\ttmpfile, err := os.CreateTemp(fcfg.StoreDir, \"_test_\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"storage directory is not writable\")\n\t}\n\n\ttmpfile.Close()\n\tdios.acquire()\n\tos.Remove(tmpfile.Name())\n\tdios.release()\n\n\tfs = &fileStore{\n\t\tfcfg:       fcfg,\n\t\tdios:       dios,\n\t\tpsim:       stree.NewSubjectTree[psi](),\n\t\tbim:        make(map[uint32]*msgBlock),\n\t\tcfg:        FileStreamInfo{Created: created, StreamConfig: cfg},\n\t\tprf:        prf,\n\t\toldprf:     oldprf,\n\t\tqch:        make(chan struct{}),\n\t\tfsld:       make(chan struct{}),\n\t\tsrv:        fcfg.srv,","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/filestore.go#L429-L465","documentation":"As a writability check, the file store creates a temporary probe file via os.CreateTemp in StoreDir; failure means the directory exists but the process cannot write to it (permissions, read-only mount, disk full). The store aborts rather than risking data loss later.","triggerScenarios":"os.CreateTemp(fcfg.StoreDir, \"_test_\") returns an error during file store creation (server/filestore.go:447).","commonSituations":"Directory owned by another user (e.g. created by root, server runs as nats); Kubernetes/Docker volume mounted read-only; full disk or noexec/quota limits.","solutions":["Grant the server process user write permission on the directory (chown/chmod)","Remount the volume read-write if mounted read-only","Free disk space or resolve quota limits","Point store_dir at a writable location"],"exampleFix":"// before\n// $ ls -ld /data/jetstream => drwxr-xr-x root root\n// after\n// $ sudo chown -R nats:nats /data/jetstream\nstore_dir: \"/data/jetstream\" // now writable by the server user","handlingStrategy":"validation","validationCode":"probe, err := os.CreateTemp(storeDir, \"_probe_\")\nif err != nil {\n    return fmt.Errorf(\"store dir not writable: %w\", err)\n}\nprobe.Close()\nos.Remove(probe.Name())","typeGuard":null,"tryCatchPattern":"if _, err := os.CreateTemp(storeDir, \"_probe_\"); err != nil {\n    return fmt.Errorf(\"store dir not writable: %w\", err)\n}","preventionTips":["Chown the data directory to the server's runtime user","Verify volumes are not mounted :ro","Monitor free disk space and inodes"],"tags":["jetstream","filesystem","permissions","disk","go"],"backgroundTag":"permission-denied","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}