nats-io/nats-server · error
OCSP storage directory is not a directory
Error message
OCSP storage directory is not a directory
What it means
Thrown by setupOCSPStapleStoreDir when os.Stat on the OCSP staple store directory (server store_dir plus the default ocsp subdirectory) succeeds but reports a non-directory entry (or a nil FileInfo), i.e. the path exists but is a regular file, symlink target, socket, etc. rather than a directory. Only the 'exists but wrong type' case triggers it; a missing directory is created via MkdirAll instead.
Source
Thrown at server/ocsp.go:577
}
}
}
return tc, mon, nil
}
func (s *Server) setupOCSPStapleStoreDir() error {
opts := s.getOpts()
storeDir := opts.StoreDir
if storeDir == _EMPTY_ {
return nil
}
storeDir = filepath.Join(storeDir, defaultOCSPStoreDir)
if stat, err := os.Stat(storeDir); os.IsNotExist(err) {
if err := os.MkdirAll(storeDir, defaultDirPerms); err != nil {
return fmt.Errorf("could not create OCSP storage directory - %v", err)
}
} else if stat == nil || !stat.IsDir() {
return fmt.Errorf("OCSP storage directory is not a directory")
}
return nil
}
type tlsConfigKind struct {
tlsConfig *tls.Config
tlsOpts *TLSConfigOpts
kind string
isLeafSpoke bool
apply func(*tls.Config)
}
func (s *Server) configureOCSP() []*tlsConfigKind {
sopts := s.getOpts()
configs := make([]*tlsConfigKind, 0)
if config := sopts.TLSConfig; config != nil {View on GitHub (pinned to 3a66a489d2)
Solutions
- Remove or rename the non-directory file occupying the OCSP store path (<store_dir>/jetstream-ocsp or the configured store_dir + default OCSP subdir) so the server can create the directory
- Set store_dir to a location where the OCSP subdirectory can be created as a real directory
- Fix permissions/ownership so the path can be replaced with a directory
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server/ocsp.go:577 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02).
Data as JSON: /api/errors/2d4dfb5ae027eb0d.
Report an issue: GitHub.