Overview
Core server options control fundamental NATS server behavior including network binding, connection limits, payload sizes, and timeouts.Command Line Flags
Network Configuration
string
default:"0.0.0.0"
Bind to host address. Specifies the network interface the server will listen on.
integer
default:"4222"
Port for client connections. The default NATS protocol port is 4222.
string
default:"auto"
Server name for identification in cluster. If not specified, a unique name is automatically generated.
string
Client URL to advertise to other servers. Useful when running behind NAT or load balancers.
Connection Limits
integer
Maximum number of concurrent client connections.Config file:
integer
Maximum number of subscriptions per connection.Config file:
Payload and Performance
integer
default:"1048576"
Maximum message payload size in bytes. Default is 1MB.Config file:
integer
default:"67108864"
Maximum number of bytes buffered for a connection. Default is 64MB.Config file:
duration
Maximum time to wait when writing to a client connection.Config file:
Monitoring
integer
HTTP port for monitoring endpoints.
integer
HTTPS port for monitoring with TLS.
Other Options
string
File path to store process ID.
string
Path to configuration file.
boolean
Test configuration file and exit without starting server.
string
Directory where a ports file will be created containing the server’s listening ports. File format:
<executable_name>_<pid>.ports.Configuration File Example
Complete Server Example
Here’s a production-ready configuration combining multiple server options:Runtime Configuration
Testing Configuration
Validate your configuration before starting the server:Starting with Options
Combine command line flags with a configuration file:Best Practices
- Connection Limits: Set
max_connectionsbased on expected load and system resources - Payload Size: Increase
max_payloadif your application sends large messages - Write Deadline: Tune
write_deadlinebased on network latency and client behavior - Monitoring: Always enable monitoring with
http_portfor production deployments - Server Name: Use descriptive server names in clusters for easier troubleshooting
- Client Advertise: Configure when behind NAT or load balancers
Related Configuration
Cluster Options
Configure server clustering and routes
JetStream Options
Enable and configure JetStream persistence
TLS Options
Secure connections with TLS