nats-io/nats-server · error

memStore requires memory storage type in config

Error message

memStore requires memory storage type in config

What it means

Raised in newMemStoreWithMode when the supplied StreamConfig has a Storage type other than MemoryStorage. The memory-store implementation can only back streams declared with memory storage, so a file-storage stream routed here is a programming/config mismatch.

Source

Thrown at server/memstore.go:67

	recovering  bool        // Timers, schedules, TTLs etc won't fire while set.
	consumers   []ConsumerStore
	receivedAny bool
	ttls        *thw.HashWheel
	scheduling  *MsgScheduling
	sdm         *SDMMeta
	sources     map[string]*StreamSourceState
}

func newMemStore(cfg *StreamConfig) (*memStore, error) {
	return newMemStoreWithMode(cfg, false)
}

func newMemStoreWithMode(cfg *StreamConfig, recovering bool) (*memStore, error) {
	if cfg == nil {
		return nil, fmt.Errorf("config required")
	}
	if cfg.Storage != MemoryStorage {
		return nil, fmt.Errorf("memStore requires memory storage type in config")
	}
	ms := &memStore{
		msgs:       make(map[uint64]*StoreMsg),
		fss:        stree.NewSubjectTree[SimpleState](),
		maxp:       cfg.MaxMsgsPer,
		cfg:        *cfg,
		recovering: recovering,
	}
	// Only create a THW if we're going to allow TTLs.
	if cfg.AllowMsgTTL {
		ms.ttls = thw.NewHashWheel()
	}
	if cfg.AllowMsgSchedules {
		ms.scheduling = newMsgScheduling(ms.runMsgScheduling)
		ms.scheduling.paused = recovering
	}
	if cfg.FirstSeq > 0 {
		if _, err := ms.purge(cfg.FirstSeq); err != nil {

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Set Storage: MemoryStorage in the stream config, or use the file store for durable streams
  2. Check stream-creation code paths so the store type is selected from cfg.Storage
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/memstore.go:67 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/9ae4304c0db405ec. Report an issue: GitHub.