Your producers start throwing JetStream publish errors: “insufficient storage”, “maximum bytes exceeded”, or “maximum messages exceeded”. The server itself looks healthy: /healthz returns ok, connections are stable, CPU and memory are normal. Writes to one or more streams are failing anyway.
This is a storage-limit failure, not a server failure. JetStream enforces limits at three levels: per-stream (max_bytes, max_msgs, max_age), per-account storage quotas, and the server-wide JetStream storage reservation. When any of them is hit, the discard policy decides the failure mode. With DiscardNew, new publishes are rejected and the publisher sees an error. With DiscardOld, the server silently evicts the oldest messages to make room, which is data loss for any consumer that has not caught up.
Rejection is invisible unless the publisher waits on the ack. A fire-and-forget publisher keeps “succeeding” while messages go nowhere. This guide covers how to identify which limit fired, which streams are involved, and how to recover without losing more data than you have to.
What this means
Every stream has limits, and the server has a storage reservation on top. When a limit is reached:
- DiscardNew: the publish is rejected. The client gets a JetStream API error on the ack (error code 10047, “insufficient storage resources available”). Synchronous publishes return the error directly; async publishes surface it on the ack future. If your publisher never waits on acks, you will not notice until someone downstream complains.
- DiscardOld (the default): the publish succeeds, but the oldest messages are deleted to make room. There is no error anywhere. Lagging consumers lose those messages permanently.
Three different limits produce the same symptom:
- Per-stream limits: the stream hit its own
max_bytesormax_msgs. Other streams on the same server may be fine. - Account-level limits: the account’s JetStream storage quota is exhausted, rejecting publishes to any stream in that account.
- Server-level reservation: the aggregate JetStream storage reservation (
reserved_storage/reserved_memory) is full. This affects every stream on the server.
A fourth cause produces identical symptoms from the outside: the underlying filesystem filled up. JetStream respects its own configured limits, but other processes on the same host can consume the disk out from under it. From the client’s perspective, writes fail either way.
flowchart TD
A[Publish rejected or messages missing] --> B{Which discard policy?}
B -->|DiscardNew| C[Publisher sees error on ack]
B -->|DiscardOld| D[Oldest messages evicted silently]
C --> E{Which limit?}
D --> E
E -->|Stream max_bytes or max_msgs| F[Fix stream limits or consumer lag]
E -->|Account quota| G[Fix account limits or shrink streams]
E -->|Server reservation| H[Free storage or raise reservation]
E -->|Filesystem full| I[Clear disk: other processes]Common causes
| Cause | What it looks like | First thing to check |
|---|---|---|
Stalled consumer with limits retention | Stream grows steadily, num_pending climbing, publishes rejected once limit hits | /jsz?consumers=true for num_pending and num_ack_pending on that stream |
Stalled consumer with interest retention | Retention cannot delete messages because a consumer has not acked them; storage grows until limit | Consumer num_ack_pending at or near MaxAckPending; first_seq not advancing |
| Unlimited or oversized stream | One stream with no effective max_bytes grows until the server reservation fills | /jsz?streams=true: compare stream bytes to reserved storage |
| Server reservation exhausted | All streams reject publishes; storage near reserved_storage in /jsz | /jsz aggregate storage vs reserved |
| Producer burst or flood | Sudden publish rate spike fills the stream faster than consumers drain it | /varz in_msgs rate vs baseline |
| Underlying disk full | Filesystem at 100%, JetStream writes fail regardless of its own limits | df -h on the JetStream store_dir filesystem |
| Cluster storage skew | One server in a JetStream cluster exhausts storage while peers have headroom (uneven leader/stream placement) | Compare /jsz storage across cluster members |
Quick checks
All of these are read-only. The monitoring port defaults to 8222.
# Aggregate JetStream storage vs the configured reservation
curl -s http://localhost:8222/jsz | jq '{bytes, messages, memory, storage, reserved_memory, reserved_storage}'
# API error counters: rising errors here include publish rejections
curl -s http://localhost:8222/jsz | jq '{api_total: .api.total, api_errors: .api.errors, inflight: .api.inflight}'
# Per-stream state: find which streams are at or near their limits
curl -s 'http://localhost:8222/jsz?streams=true' | jq '.account_details[].stream_detail[] | {name, messages: .state.messages, bytes: .state.bytes, first_seq: .state.first_seq, last_seq: .state.last_seq, consumers: .state.consumer_count}'
# Per-consumer state: find stalled consumers on the affected stream
curl -s 'http://localhost:8222/jsz?consumers=true' | jq '.account_details[].streams[].consumer[] | {name, num_pending, num_ack_pending, num_redelivered}'
# Underlying filesystem on the JetStream store directory
df -h /path/to/jetstream/store_dir
If you have the nats CLI, nats stream report and nats stream info <stream> give the same per-stream picture, and nats consumer info <stream> <consumer> shows the detailed ack state.
How to diagnose it
Confirm the failure mode. Are publishers seeing errors (DiscardNew) or are consumers reporting gaps (DiscardOld eviction)? Check the stream’s discard policy with
nats stream info. If DiscardOld, assume data loss has already occurred for lagging consumers and scope the damage via consumernum_pendingand sequence gaps.Identify which limit fired. Compare per-stream
state.bytesagainst the configuredmax_bytesfrom/jsz?streams=true. If no individual stream is at its limit butstorageis nearreserved_storagein/jsz, the server-level reservation is the binding constraint. If only streams in one account are affected while the server has headroom, suspect the account-level quota.Find the growth driver. A stream fills because publishes outpace deletion. Deletion happens via retention (age/limits), consumer acknowledgment (interest/workqueue retention), or DiscardOld eviction. If
first_seqis not advancing whilelast_seqclimbs, messages are accumulating. That almost always means a stalled or slow consumer, not a publisher problem.Check the consumers on the affected stream. Growing
num_pendingmeans delivery is falling behind.num_ack_pendingpinned at the consumer’sMaxAckPendingmeans delivery has stopped entirely: the server will not send more until acks arrive. Withinterestretention, one stalled consumer blocks retention for the whole stream.Check the filesystem independently. Even when JetStream reports headroom against its own reservation, run
dfon the store directory. Log files, core dumps, or co-located processes can fill the disk. JetStream cannot write what the filesystem will not give it.In a cluster, compare members. Pull
/jszstorage on every node. If one server is at its reservation while peers are not, stream and leader placement is skewed. The per-server limit is what matters; cluster totals hide this.
Metrics and signals to monitor
| Signal | Why it matters | Warning sign |
|---|---|---|
/jsz storage / reserved_storage | How full the server-wide JetStream reservation is | Ratio approaching 90%, or a linear growth trend with a computable time-to-exhaustion |
/jsz api.errors rate | Publish rejections and other JetStream failures surface here | Any sustained positive rate; errors/total above a few percent |
Per-stream state.bytes vs max_bytes | The per-stream limit fires before the server limit when streams are individually sized | Ratio above 0.8 on any stream |
Consumer num_pending growth | Consumers falling behind is the most common reason streams fill | Sustained positive growth rate |
Consumer num_ack_pending vs MaxAckPending | At the limit, delivery stalls and interest-based retention blocks | Ratio above 0.8 |
Stream first_seq movement | A static first_seq with a climbing last_seq means accumulation | first_seq frozen while publishes continue |
Filesystem usage on store_dir | JetStream limits do not protect against other processes filling the disk | Above 80% |
/jsz api.inflight | Sustained high inflight with rising errors points at Raft or disk trouble rather than a pure capacity issue | Elevated inflight plus rising error rate |
Fixes
Unblock the stalled consumer
This is the most common root cause and the right first fix. If the consumer application is down, restart it. If num_ack_pending is pinned at MaxAckPending, the consumer is connected but not acking: look for a hung processing loop, a downstream dependency failure, or an AckWait shorter than actual processing time (messages get redelivered without ever completing).
If the consumer is genuinely dead and cannot be revived quickly, deleting it makes its pending messages eligible for deletion under interest retention. That is destructive: those messages may be removed. Do it deliberately, not reflexively.
Purge or trim the stream
If the accumulated messages have no remaining value (or the data is reproducible), purging the stream frees space immediately. This is destructive: purged messages are gone. Prefer trimming by age or sequence over a full purge when only the oldest data is expendable.
Raise the limit that fired
If the workload has legitimately outgrown the stream, increase max_bytes on the stream, the account quota, or the server reservation, whichever is binding. Tradeoffs: a bigger stream means longer recovery on restart (JetStream replays and reindexes its store), more disk, and a bigger blast radius the next time a consumer stalls. Raising limits without fixing consumer lag only buys time.
Recover server-level headroom
When the server reservation is the constraint: shrink or delete streams you no longer need, reduce replica counts to free space on removed replicas, or raise the reservation if the disk supports it. Note that deleting a stream does not always release the reservation accounting instantly; recreating a same-sized stream immediately after deletion can fail with the same “insufficient storage” error . In clustered setups there is no live stream migration, so rebalancing means adjusting replicas and placement, not moving streams.
Fix the filesystem
If df shows the disk full while JetStream reports headroom, the fix is outside NATS: clear the co-located logs, core dumps, or whatever consumed the space. Longer term, put the JetStream store_dir on a dedicated filesystem so nothing else can fill it.
Prevention
- Set explicit limits on every stream. A stream created without
max_bytes,max_msgs, ormax_agegrows until it hits the account or server limit. Unlimited streams are the most common cause of server-level exhaustion. - Choose discard policies deliberately.
DiscardOld(default) converts a full stream into silent data loss.DiscardNewconverts it into visible publisher errors. Neither is “safe”; pick per stream based on whether producers or consumers should absorb the backpressure, and make sure publishers check acks where DiscardNew is used. - Monitor the ratio, not the absolute. Alert on
storage / reserved_storageapproaching 90% and per-streambytes / max_bytesabove 0.8, with enough lead time to act before rejection starts. - Monitor consumer lag as the leading indicator.
num_pendinggrowth andnum_ack_pendingsaturation warn you long before storage fills. Storage is the capacity metric; lag is the operational one. - Reserve overhead beyond stream limits. Clustered JetStream consumes storage beyond raw message data (Raft logs, consumer state, compaction). Leave headroom between the sum of stream limits and the server reservation rather than sizing them exactly equal.
- Give JetStream its own filesystem. A dedicated
store_dirfilesystem removes the “someone else filled the disk” failure mode entirely.
How Netdata helps
- Netdata’s NATS collector polls the HTTP monitoring endpoints and tracks aggregate JetStream storage, memory, and reserved quotas from
/jsz, so you see the reservation filling as a trend instead of discovering it at 100%. - The JetStream API error rate (
api.errorsvsapi.total) is charted over time, which is where DiscardNew publish rejections become visible as a rising error rate instead of scattered client-side exceptions. - Correlating storage growth against message throughput (
in_msgsrate) separates a producer burst from a consumer stall: throughput flat while storage climbs points at consumers. - Per-second collection catches the acceleration at the end of a fill event, which 60-second scrape intervals routinely miss.
- Alerting on the storage/reserved ratio with trend-based time-to-exhaustion gives you lead time to fix a stalled consumer before rejection starts, which is the difference between a ticket and data loss.
Related guides
- NATS context deadline exceeded: JetStream publish and request timeouts
- NATS JetStream disabled unexpectedly: the persistence subsystem failed to come up
- NATS /healthz explained: js-server-only vs js-enabled-only vs the bare check
- NATS monitoring checklist: the signals every production server needs
- NATS messages published but not received: subject mismatches and cross-server gaps
- How NATS actually works in production: a mental model for operators






