Skip to main content
Server options control the core behavior of the NATS server including network binding, monitoring, and server identification.

Command Syntax

Server Options Reference

string
default:"0.0.0.0"
Bind to host address. Specifies the network interface the server listens on for client connections.Examples:
number
default:"4222"
Use port for client connections. The default NATS client port is 4222.Examples:
string
default:"auto"
Server name for identification. If not specified, a unique name is automatically generated.Examples:
string
File to store the server’s process ID. Useful for process management and sending signals.Examples:
number
Use port for HTTP monitoring endpoint. Enables the monitoring interface at http://<host>:<port>/varz, /connz, /subsz, etc.Examples:
Access monitoring endpoints:
  • http://localhost:8222/varz - General server information
  • http://localhost:8222/connz - Connection information
  • http://localhost:8222/subsz - Subscription information
number
Use port for HTTPS monitoring. Same as -m but serves monitoring endpoints over HTTPS.Examples:
string
Configuration file path. The configuration file uses a flexible format for complex setups.Examples:
boolean
Test configuration and exit. Validates the configuration file without starting the server.Examples:
The server will print whether the configuration is valid and exit with status 0 on success.
string
Send signal to nats-server process. Used for process management without direct PID access.Format: --signal <signal>[=<pid>]Signals: ldm, stop, quit, term, reopen, reloadSee Signals for detailed usage.
string
Client URL to advertise to other servers. Useful when the server is behind NAT or in containerized environments.Examples:
string
Creates a ports file in the specified directory. The file is named <executable_name>_<pid>.ports and contains the actual ports the server is listening on.Examples:
This creates a file like /var/run/nats/nats-server_12345.ports containing:
Useful when using -1 for random port assignment.

Complete Examples

Basic Server

Production Server

Development Server with Custom Name

Server Behind NAT

Testing Configuration