Skip to main content
NATS server supports signal handling for graceful operations like reloading configuration, rotating logs, and shutting down.

Signal Command

Use the --signal flag to send signals to a running NATS server process:

Signal Format

string
required
The signal to send. Available signals: ldm, stop, quit, term, reopen, reload
string
Process identifier. Can be either:
  • A numeric PID (e.g., 1234)
  • Path to a PID file (e.g., /var/run/nats-server.pid)
If not specified, signals are sent to all nats-server processes.

Available Signals

ldm - Log Debug and Memory

Dumps current goroutine stack traces and memory stats to the log. Usage:
Output Location:
  • Written to the configured log file (if -l was used)
  • Written to stdout if no log file configured
Use Cases:
  • Debugging deadlocks
  • Investigating high memory usage
  • Troubleshooting performance issues

stop - Graceful Shutdown

Initiates graceful shutdown of the server. The server will:
  1. Stop accepting new connections
  2. Wait for existing clients to disconnect
  3. Flush pending messages
  4. Exit cleanly
Usage:
Equivalent System Signals:
  • SIGINT (Ctrl+C)
  • SIGTERM

quit - Immediate Shutdown

Immediately terminates the server without graceful cleanup. Usage:
Use quit only when stop fails or immediate termination is required. Prefer stop for graceful shutdown.
Equivalent System Signal:
  • SIGQUIT

term - Terminate

Similar to stop, initiates graceful shutdown. Usage:
Equivalent System Signal:
  • SIGTERM

reopen - Rotate Log File

Reopens the log file. Used for log rotation with external tools like logrotate. Usage:
Log Rotation Workflow:
  1. External tool moves/renames the current log file
  2. Send reopen signal to nats-server
  3. Server closes old file handle and opens new log file
Example with logrotate:
Manual Rotation:

reload - Reload Configuration

Reloads the server configuration from the config file without restarting. Usage:
What Gets Reloaded:
  • User credentials
  • Permissions
  • Account definitions
  • Log level
  • Debug/trace flags
  • Log file path
  • Cluster permissions
  • Authorization
  • HTTP monitoring port settings
What Cannot Be Reloaded:
  • Listen address and port
  • Server name
  • Cluster URL
  • JetStream storage directory
  • TLS certificates (requires restart)
Example:
Output:

Using PID Files

For reliable signal delivery, start the server with a PID file:

System Signal Equivalents

You can also send signals directly using standard Unix tools:

Complete Examples

Production Server with Signal Support

Debug Running Server

Update Authorization

Emergency Shutdown

Systemd Integration

For systemd-managed servers, signals are handled automatically:
Usage: