hashicorp/nomad · error

no raft store (raft.db or wal/) found in %s

Error message

no raft store (raft.db or wal/) found in %s

What it means

FindRaftStore locates a raft log store — either a wal/ directory (WAL backend) or a raft.db file (BoltDB backend) — under path p by checking well-known locations and then walking the tree for raft.db. This error means none of the candidate locations existed and the filesystem walk also failed to find a raft.db file, so p does not contain a usable raft store.

Source

Thrown at helper/raftutil/state.go:280

			continue
		}
		if c.isDir && info.IsDir() {
			return c.path, nil
		}
		if !c.isDir && !info.IsDir() {
			return c.path, nil
		}
	}

	// Accept a direct path to a .db file.
	if info, statErr := os.Stat(p); statErr == nil && !info.IsDir() && filepath.Ext(p) == ".db" {
		return p, nil
	}

	// Fall back to filesystem walk for raft.db.
	storePath, err = FindFileInPath("raft.db", p)
	if err != nil {
		return "", fmt.Errorf("no raft store (raft.db or wal/) found in %s", p)
	}
	return storePath, nil
}

// FindRaftFile finds raft.db and returns its path. This is a compatibility
// wrapper; prefer FindRaftStore for code that supports both backends.
func FindRaftFile(p string) (raftpath string, err error) {
	// Try known locations before traversal to avoid walking deep structure
	if _, err = os.Stat(filepath.Join(p, "server", "raft", "raft.db")); err == nil {
		raftpath = filepath.Join(p, "server", "raft", "raft.db")
	} else if _, err = os.Stat(filepath.Join(p, "raft", "raft.db")); err == nil {
		raftpath = filepath.Join(p, "raft", "raft.db")
	} else if _, err = os.Stat(filepath.Join(p, "raft.db")); err == nil {
		raftpath = filepath.Join(p, "raft.db")
	} else if _, err = os.Stat(p); err == nil && filepath.Ext(p) == ".db" {
		// Also accept path to .db file
		raftpath = p
	} else {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Point the tool at the Nomad server's data_dir (the directory containing server/raft/) — e.g. nomad server data_dir or its default /var/lib/nomad.
  2. Verify the path exists and list it: ls <p>/server/raft — you should see raft.db or wal/; adjust the path if not.
  3. If you have a direct store file, pass its full path ending in .db (accepted as a direct raft.db path) or the wal/ directory itself.
  4. Restore the server data directory from backup before running inspection/FSM tooling if the store was deleted.
  5. If using FindRaftFile with an old layout, confirm the backend: WAL deployments will never contain raft.db, so use FindRaftStore, not the raft.db-only wrapper.

Example fix

// before: wrong path — agent config dir has no raft state
path, err := raftutil.FindRaftStore("/etc/nomad.d")
// after: use the server data dir (or accept a direct .db path)
dataDir := "/var/lib/nomad" // nomad agent's data_dir
path, err := raftutil.FindRaftStore(dataDir)
if err != nil {
    // or: raftutil.FindRaftStore(filepath.Join(dataDir, "server", "raft", "raft.db"))
    log.Fatalf("no raft store under %s: %v", dataDir, err)
}
Defensive patterns

Strategy: validation

Validate before calling

func hasRaftStore(p string) bool {
    for _, c := range []string{
        filepath.Join(p, "server", "raft", "wal"),
        filepath.Join(p, "raft", "wal"),
        filepath.Join(p, "wal"),
        filepath.Join(p, "server", "raft", "raft.db"),
        filepath.Join(p, "raft", "raft.db"),
        filepath.Join(p, "raft.db"),
    } {
        if _, err := os.Stat(c); err == nil { return true }
    }
    return false
}
// call hasRaftStore(dataDir) before FindRaftStore

Try / catch

storePath, err := raftutil.FindRaftStore(dataDir)
if err != nil {
    if strings.Contains(err.Error(), "no raft store") {
        return fmt.Errorf("%q is not a Nomad server data dir (no raft.db or wal/): %w", dataDir, err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling FindRaftStore (directly or via FindRaftDir / Run / NewFSM) with a path p that contains neither server/raft/wal, raft/wal, wal, server/raft/raft.db, raft/raft.db, raft.db, a direct *.db file, nor any raft.db found by walking the tree.

Common situations: Passing the Nomad agent config dir or /tmp instead of the data_dir (default /var/lib/nomad or the configured client/server data dir); pointing at a client-only data dir which has no server/raft state; a wiped or never-initialized server data directory; typos or wrong mount paths in recovery tooling.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/2e90dcd7a4650a2b. Report an issue: GitHub.