Skip to content

Troubleshooting

Outcome: the failures this guide's own lab actually met, each with the evidence that named it — so yours take minutes, not afternoons.

"No servers available for connection"

$ nats pub greetings "anyone?" --server nats://127.0.0.1:18099
nats: error: nats: no servers available for connection

(t12.) The client could not open a connection at all. In order of likelihood: the server is not running (check its log, or curl its /healthz — silence means down); the port in the address is not the port the server listens on (chapter 3's -p, and the config file's listen: — a server on 18084 does not hear 4222); or a firewall stands between. The error says nothing about authorisation — door unanswered and door locked are different messages, below.

"Authorization Violation"

nats: error: nats: Authorization Violation

(t10, t11.) A server answered and refused the credentials: no token where one is required, the wrong token, or a user the config does not know. Three suspects, in order: the address's credentials (nats://user:pass@host — note a token travels in the user position, with no password); the config the server actually loaded (restart it and read its log header); and stale eyes — an old terminal where the same command worked before the server grew a lock.

"Permissions Violation for Publish to …"

nats: permissions violation: Permissions Violation for Publish to "greetings"

(t11.) Different failure: the user is known, the subject is fenced. Read the message literally — it names the direction and the subject. Then check the permissions block in the config (chapter 10), remembering the two easy misses: subscribe permissions are a separate list from publish, and a request/reply user needs _INBOX.> in the subscribe list or answers cannot come home.

The request that got "No responders are available"

That one is not an error in the machinery — it is the machinery reporting, instantly, that no subscriber exists on the subject (chapter 6, t04). Confirm with a deliberately deaf ear: nats sub thesubject in another window should show the request arrive. If it does, the responder's subject differs from the asker's — a spelling difference in a tree is still a different tree.

The responder that answers with nothing

Chapter 6's found trap: a nats reply --command whose command string contained % (a date format) replied with an empty body, every time, while --command "echo hello-from-command" worked (t04). If your computed replies come back blank, suspect the command string's own characters — % and the CLI's {{ }} subject templates — before suspecting your command. Test the command alone in a shell; then test the responder with a static body; the layer that changes behaviour is the culprit.

The command that stops dead in a script

nats: error: invalid input: cannot ask for confirmation without a terminal

(t06.) Several nats administration commands, given incomplete settings, ask questions interactively — and refuse when there is no terminal to ask. In scripts and in this lab alike, the fix is to stop being incomplete: give the full configuration by file (stream add --config, consumer add --config), as chapters 8 does, or pass every setting as a flag. The same family produces could not pick a Stream … without a terminal when a command needs a name you did not give it.

Messages missing where you expected them

Work the delivery ladder (chapter 13) as a checklist:

  1. Were they ever kept? Published before the stream existed, or on a core-only subject — gone by design (t06's first three, t02's early message).
  2. Was the subscription's pattern deep enough? A * where the tree runs two words deep is silent, legal and wrong (chapter 5's table).
  3. Did the shell eat the wildcard? Unquoted * and > are the shell's before they are NATS's. Quote patterns, always.
  4. Alive at the time? Core delivery is to the connected (chapter 4); check the consumer's state, not the client's hope, for JetStream: nats consumer info.
  5. Acknowledged but failed? A message handled badly and acknowledged is done — the server believed you. Chapter 8's rule: acknowledge at the end of the work, not the beginning.

The server will not start, or starts wrong

Read the first twenty lines of its log before anything else (t01 shows a healthy opening). The usual entries: the port is already in use (another server — yours, from an earlier experiment, is the commonest squatter); the JetStream store directory is not writable by the server's user; the config file has a brace unbalanced, and the log says which line. And if the server is healthy but JetStream commands claim it is not enabled, the server was started without -js, or the config file overrode the flags you remember giving it.

Check: each heading above is recognisable from its error text alone. If your failure matches none, the server log and /varz are the next two reads — they were the lab's first resort every time, and they are yours.