> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/nats-io/nats-server/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Overview

> Introduction to nats-server command-line interface

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

```bash theme={null}
nats-server [options]
```

Start a NATS server with default settings:

```bash theme={null}
nats-server
```

This starts the server listening on `0.0.0.0:4222` with auto-generated server name.

## Common Usage Patterns

### Starting with Custom Port

```bash theme={null}
nats-server -p 4223
```

### Using a Configuration File

```bash theme={null}
nats-server -c /etc/nats/nats-server.conf
```

### Testing Configuration

Validate your configuration file without starting the server:

```bash theme={null}
nats-server -c /etc/nats/nats-server.conf -t
```

### Enable JetStream with Custom Storage

```bash theme={null}
nats-server -js -sd /var/lib/nats
```

### Enable Monitoring

```bash theme={null}
nats-server -m 8222
```

Access monitoring interface at `http://localhost:8222`

### Debug Mode with Logging

```bash theme={null}
nats-server -D -l /var/log/nats-server.log
```

## 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:

```bash theme={null}
nats-server -c nats.conf -D -p 4223
```

This loads `nats.conf` but overrides the port to 4223 and enables debug mode.

## Help and Version

### Display Help

```bash theme={null}
nats-server -h
nats-server --help
```

### Show Version

```bash theme={null}
nats-server -v
nats-server --version
```

### TLS Help

```bash theme={null}
nats-server --help_tls
```

## Common Flag Combinations

### Production Server with Monitoring

```bash theme={null}
nats-server -c /etc/nats/nats-server.conf -P /var/run/nats-server.pid -m 8222 -l /var/log/nats-server.log
```

### Development with Debug and Trace

```bash theme={null}
nats-server -DV -p 4222
```

### JetStream with Monitoring and Logging

```bash theme={null}
nats-server -js -sd /data/jetstream -m 8222 -l /var/log/nats.log
```

### Clustered Server

```bash theme={null}
nats-server -c cluster.conf --cluster nats://0.0.0.0:6222 --routes nats://node1:6222,nats://node2:6222
```

## Next Steps

* [Server Options](/cli/server-options) - Complete reference of server CLI flags
* [Logging Options](/cli/logging-options) - Configure logging and debugging
* [Signals](/cli/signals) - Signal handling and process management
