Command Line Arguments

The NATS Streaming Server accepts command line arguments to control its behavior. There is a set of parameters specific to the NATS Streaming Server and some to the embedded NATS Server.

Command line parameters override corresponding config options in a configuration file, which themselves override configuration defaults. Configuration defaults can be found on the Configuration File page.

Note about parameters types

Type Remark
<bool> For booleans, either simply specify the parameter with value to enable (e.g -SD), or specify =false to disable
<size> You can specify as a number 1024 or as a size 1KB
<duration> Values must be expressed in the form _h_m_s, such as 1h or 20s or 1h30m, or 1.5h, etc…
  1. Usage: nats-streaming-server [options]
  2. Streaming Server Options:
  3. -cid, --cluster_id <string> Cluster ID (default: test-cluster)
  4. -st, --store <string> Store type: MEMORY|FILE|SQL (default: MEMORY)
  5. --dir <string> For FILE store type, this is the root directory
  6. -mc, --max_channels <int> Max number of channels (0 for unlimited)
  7. -msu, --max_subs <int> Max number of subscriptions per channel (0 for unlimited)
  8. -mm, --max_msgs <int> Max number of messages per channel (0 for unlimited)
  9. -mb, --max_bytes <size> Max messages total size per channel (0 for unlimited)
  10. -ma, --max_age <duration> Max duration a message can be stored ("0s" for unlimited)
  11. -mi, --max_inactivity <duration> Max inactivity (no new message, no subscription) after which a channel can be garbage collected (0 for unlimited)
  12. -ns, --nats_server <string> Connect to this external NATS Server URL (embedded otherwise)
  13. -sc, --stan_config <string> Streaming server configuration file
  14. -hbi, --hb_interval <duration> Interval at which server sends heartbeat to a client
  15. -hbt, --hb_timeout <duration> How long server waits for a heartbeat response
  16. -hbf, --hb_fail_count <int> Number of failed heartbeats before server closes the client connection
  17. --ft_group <string> Name of the FT Group. A group can be 2 or more servers with a single active server and all sharing the same datastore
  18. -sl, --signal <signal>[=<pid>] Send signal to nats-streaming-server process (stop, quit, reopen)
  19. --encrypt <bool> Specify if server should use encryption at rest
  20. --encryption_cipher <string> Cipher to use for encryption. Currently support AES and CHAHA (ChaChaPoly). Defaults to AES
  21. --encryption_key <string> Encryption Key. It is recommended to specify it through the NATS_STREAMING_ENCRYPTION_KEY environment variable instead
  22. Streaming Server Clustering Options:
  23. --clustered <bool> Run the server in a clustered configuration (default: false)
  24. --cluster_node_id <string> ID of the node within the cluster if there is no stored ID (default: random UUID)
  25. --cluster_bootstrap <bool> Bootstrap the cluster if there is no existing state by electing self as leader (default: false)
  26. --cluster_peers <string, ...> Comma separated list of cluster peer node IDs to bootstrap cluster state
  27. --cluster_log_path <string> Directory to store log replication data
  28. --cluster_log_cache_size <int> Number of log entries to cache in memory to reduce disk IO (default: 512)
  29. --cluster_log_snapshots <int> Number of log snapshots to retain (default: 2)
  30. --cluster_trailing_logs <int> Number of log entries to leave after a snapshot and compaction
  31. --cluster_sync <bool> Do a file sync after every write to the replication log and message store
  32. --cluster_raft_logging <bool> Enable logging from the Raft library (disabled by default)
  33. Streaming Server File Store Options:
  34. --file_compact_enabled <bool> Enable file compaction
  35. --file_compact_frag <int> File fragmentation threshold for compaction
  36. --file_compact_interval <int> Minimum interval (in seconds) between file compactions
  37. --file_compact_min_size <size> Minimum file size for compaction
  38. --file_buffer_size <size> File buffer size (in bytes)
  39. --file_crc <bool> Enable file CRC-32 checksum
  40. --file_crc_poly <int> Polynomial used to make the table used for CRC-32 checksum
  41. --file_sync <bool> Enable File.Sync on Flush
  42. --file_slice_max_msgs <int> Maximum number of messages per file slice (subject to channel limits)
  43. --file_slice_max_bytes <size> Maximum file slice size - including index file (subject to channel limits)
  44. --file_slice_max_age <duration> Maximum file slice duration starting when the first message is stored (subject to channel limits)
  45. --file_slice_archive_script <string> Path to script to use if you want to archive a file slice being removed
  46. --file_fds_limit <int> Store will try to use no more file descriptors than this given limit
  47. --file_parallel_recovery <int> On startup, number of channels that can be recovered in parallel
  48. --file_truncate_bad_eof <bool> Truncate files for which there is an unexpected EOF on recovery, dataloss may occur
  49. --file_read_buffer_size <size> Size of messages read ahead buffer (0 to disable)
  50. --file_auto_sync <duration> Interval at which the store should be automatically flushed and sync'ed on disk (<= 0 to disable)
  51. Streaming Server SQL Store Options:
  52. --sql_driver <string> Name of the SQL Driver ("mysql" or "postgres")
  53. --sql_source <string> Datasource used when opening an SQL connection to the database
  54. --sql_no_caching <bool> Enable/Disable caching for improved performance
  55. --sql_max_open_conns <int> Maximum number of opened connections to the database
  56. Streaming Server TLS Options:
  57. -secure <bool> Use a TLS connection to the NATS server without
  58. verification; weaker than specifying certificates.
  59. -tls_client_key <string> Client key for the streaming server
  60. -tls_client_cert <string> Client certificate for the streaming server
  61. -tls_client_cacert <string> Client certificate CA for the streaming server
  62. Streaming Server Logging Options:
  63. -SD, --stan_debug=<bool> Enable STAN debugging output
  64. -SV, --stan_trace=<bool> Trace the raw STAN protocol
  65. -SDV Debug and trace STAN
  66. --syslog_name On Windows, when running several servers as a service, use this name for the event source
  67. (See additional NATS logging options below)
  68. Embedded NATS Server Options:
  69. -a, --addr <string> Bind to host address (default: 0.0.0.0)
  70. -p, --port <int> Use port for clients (default: 4222)
  71. -P, --pid <string> File to store PID
  72. -m, --http_port <int> Use port for http monitoring
  73. -ms,--https_port <int> Use port for https monitoring
  74. -c, --config <string> Configuration file
  75. Logging Options:
  76. -l, --log <string> File to redirect log output
  77. -T, --logtime=<bool> Timestamp log entries (default: true)
  78. -s, --syslog <string> Enable syslog as log method
  79. -r, --remote_syslog <string> Syslog server addr (udp://localhost:514)
  80. -D, --debug=<bool> Enable debugging output
  81. -V, --trace=<bool> Trace the raw protocol
  82. -DV Debug and trace
  83. Authorization Options:
  84. --user <string> User required for connections
  85. --pass <string> Password required for connections
  86. --auth <string> Authorization token required for connections
  87. TLS Options:
  88. --tls=<bool> Enable TLS, do not verify clients (default: false)
  89. --tlscert <string> Server certificate file
  90. --tlskey <string> Private key for server certificate
  91. --tlsverify=<bool> Enable TLS, verify client certificates
  92. --tlscacert <string> Client certificate CA for verification
  93. NATS Clustering Options:
  94. --routes <string, ...> Routes to solicit and connect
  95. --cluster <string> Cluster URL for solicited routes
  96. Common Options:
  97. -h, --help Show this message
  98. -v, --version Show version
  99. --help_tls TLS help.