nats-server command-line interface provides a flexible way to start and configure NATS server instances. You can specify options directly via command-line flags or use a configuration file for more complex setups.
Basic Usage
0.0.0.0:4222 with auto-generated server name.
Common Usage Patterns
Starting with Custom Port
Using a Configuration File
Testing Configuration
Validate your configuration file without starting the server:Enable JetStream with Custom Storage
Enable Monitoring
http://localhost:8222
Debug Mode with Logging
Configuration File vs CLI Flags
You can configure NATS server using either CLI flags or a configuration file:- CLI Flags: Quick setup, ideal for development and testing
- Configuration File: Better for production, supports complex configurations including clusters, accounts, and authorization
nats.conf but overrides the port to 4223 and enables debug mode.
Help and Version
Display Help
Show Version
TLS Help
Common Flag Combinations
Production Server with Monitoring
Development with Debug and Trace
JetStream with Monitoring and Logging
Clustered Server
Next Steps
- Server Options - Complete reference of server CLI flags
- Logging Options - Configure logging and debugging
- Signals - Signal handling and process management