Skip to main content
The 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

Start a NATS server with default settings:
This starts the server listening on 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

Access monitoring interface at 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
CLI flags take precedence over configuration file settings. You can combine both approaches:
This loads 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