Overview
Core server options control fundamental NATS server behavior including network binding, connection limits, payload sizes, and timeouts.Command Line Flags
Network Configuration
Bind to host address. Specifies the network interface the server will listen on.
Port for client connections. The default NATS protocol port is 4222.
Server name for identification in cluster. If not specified, a unique name is automatically generated.
Client URL to advertise to other servers. Useful when running behind NAT or load balancers.
Connection Limits
Maximum number of concurrent client connections.Config file:
Maximum number of subscriptions per connection.Config file:
Payload and Performance
Maximum message payload size in bytes. Default is 1MB.Config file:
Maximum number of bytes buffered for a connection. Default is 64MB.Config file:
Maximum time to wait when writing to a client connection.Config file:
Monitoring
HTTP port for monitoring endpoints.
HTTPS port for monitoring with TLS.
Other Options
File path to store process ID.
Path to configuration file.
Test configuration file and exit without starting server.
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