Skip to main content
NATS Server is distributed as a single, self-contained binary with no external dependencies. This makes it easy to download, install, and run on any platform.

Download Locations

Official NATS Server binaries are available from:

Latest Version

Download the latest stable release:
curl -L https://github.com/nats-io/nats-server/releases/latest/download/nats-server-v2.10.0-linux-amd64.tar.gz -o nats-server.tar.gz
tar -xzf nats-server.tar.gz
cp nats-server-v2.10.0-linux-amd64/nats-server /usr/local/bin/
Replace v2.10.0 with the actual latest version number from the releases page.

Platform-Specific Installation

Linux

Quick Installation

# Download and install to /usr/local/bin
curl -sf https://binaries.nats.dev/nats-io/nats-server@latest | sh

Manual Installation

# Download the binary
wget https://github.com/nats-io/nats-server/releases/latest/download/nats-server-v2.10.0-linux-amd64.tar.gz

# Extract
tar -xzf nats-server-v2.10.0-linux-amd64.tar.gz

# Move to PATH
sudo mv nats-server-v2.10.0-linux-amd64/nats-server /usr/local/bin/

# Make executable
sudo chmod +x /usr/local/bin/nats-server

# Verify installation
nats-server --version

Package Managers

brew install nats-server

macOS

brew install nats-server

Manual Installation

# Download for your architecture
curl -L https://github.com/nats-io/nats-server/releases/latest/download/nats-server-v2.10.0-darwin-arm64.tar.gz -o nats-server.tar.gz

# Extract
tar -xzf nats-server.tar.gz

# Move to PATH
sudo mv nats-server-v2.10.0-darwin-arm64/nats-server /usr/local/bin/

# Verify installation
nats-server --version

Windows

Manual Installation

  1. Download the Windows ZIP from GitHub Releases
  2. Extract the ZIP file
  3. Move nats-server.exe to a directory in your PATH (e.g., C:\Windows\System32)
  4. Verify installation:
nats-server --version

Chocolatey

choco install nats-server

Scoop

scoop install nats-server

Running NATS Server

Basic Usage

Start NATS with default settings:
nats-server
The server will:
  • Listen on port 4222 for client connections
  • Listen on 0.0.0.0 (all interfaces)
  • Run in the foreground

With Configuration File

nats-server -c /path/to/nats-server.conf

Command Line Options

nats-server --port 4222 --http_port 8222 --log /var/log/nats.log
Common options:
  • -p, --port - Client connection port (default: 4222)
  • -a, --addr - Network address to bind (default: 0.0.0.0)
  • -m, --http_port - HTTP monitoring port
  • -c, --config - Configuration file path
  • -l, --log - Log file path
  • -D, --debug - Enable debug logging
  • -V, --trace - Enable trace logging
  • -js - Enable JetStream
  • --sd - JetStream storage directory

Enable JetStream

nats-server -js -sd /data/nats

Running as a Service

systemd (Linux)

Create a systemd service file:
/etc/systemd/system/nats-server.service
[Unit]
Description=NATS Server
After=network.target

[Service]
Type=simple
User=nats
Group=nats
ExecStart=/usr/local/bin/nats-server -c /etc/nats/nats-server.conf
ExecReload=/bin/kill -s HUP $MAINPID
Restart=on-failure
RestartSec=5s
LimitNOFILE=65536

# Security settings
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/nats /var/log/nats
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target
Set up the service:
# Create nats user
sudo useradd -r -s /bin/false nats

# Create necessary directories
sudo mkdir -p /etc/nats /var/lib/nats /var/log/nats
sudo chown nats:nats /var/lib/nats /var/log/nats

# Copy configuration
sudo cp nats-server.conf /etc/nats/

# Reload systemd
sudo systemctl daemon-reload

# Enable and start service
sudo systemctl enable nats-server
sudo systemctl start nats-server

# Check status
sudo systemctl status nats-server

launchd (macOS)

Create a launch agent:
~/Library/LaunchAgents/io.nats.nats-server.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>io.nats.nats-server</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/nats-server</string>
        <string>-c</string>
        <string>/usr/local/etc/nats-server.conf</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/usr/local/var/log/nats-server.log</string>
    <key>StandardOutPath</key>
    <string>/usr/local/var/log/nats-server.log</string>
</dict>
</plist>
Load the service:
launchctl load ~/Library/LaunchAgents/io.nats.nats-server.plist

Windows Service

Use NSSM (Non-Sucking Service Manager):
# Install NSSM
choco install nssm

# Install NATS as a service
nssm install NATS "C:\Program Files\nats-server\nats-server.exe" "-c" "C:\Program Files\nats-server\nats-server.conf"

# Start the service
nssm start NATS

# Check status
nssm status NATS

Updating and Upgrading

Manual Update

  1. Download the new version
  2. Stop the running server
  3. Replace the binary
  4. Restart the server
# Stop the service
sudo systemctl stop nats-server

# Download new version
wget https://github.com/nats-io/nats-server/releases/download/v2.11.0/nats-server-v2.11.0-linux-amd64.tar.gz

# Extract and replace
tar -xzf nats-server-v2.11.0-linux-amd64.tar.gz
sudo mv nats-server-v2.11.0-linux-amd64/nats-server /usr/local/bin/

# Start the service
sudo systemctl start nats-server

# Verify version
nats-server --version

Package Manager Updates

brew upgrade nats-server

Zero-Downtime Updates

For clustered deployments, update nodes one at a time:
# Update each node sequentially
for node in node1 node2 node3; do
  ssh $node 'systemctl stop nats-server && \
             wget ... && \
             systemctl start nats-server'
  sleep 30  # Allow cluster to stabilize
done

Verifying Installation

Check Version

nats-server --version

Test Configuration

nats-server -c /path/to/nats-server.conf -t
The -t flag validates configuration without starting the server.

Test Connection

# Start server
nats-server &

# Test with nats CLI (if installed)
nats pub test "Hello World"

# Or use telnet
telnet localhost 4222

Security Considerations

Always run NATS Server as a non-root user in production environments.

File Permissions

# Binary permissions
sudo chmod 755 /usr/local/bin/nats-server

# Configuration file (may contain secrets)
sudo chmod 600 /etc/nats/nats-server.conf
sudo chown nats:nats /etc/nats/nats-server.conf

Firewall Rules

Allow necessary ports:
# UFW (Ubuntu)
sudo ufw allow 4222/tcp  # Client connections
sudo ufw allow 6222/tcp  # Cluster routes
sudo ufw allow 8222/tcp  # Monitoring (restrict to internal network)

# firewalld (CentOS/RHEL)
sudo firewall-cmd --permanent --add-port=4222/tcp
sudo firewall-cmd --permanent --add-port=6222/tcp
sudo firewall-cmd --permanent --add-port=8222/tcp
sudo firewall-cmd --reload

Best Practices

Use Configuration Files

Store configuration in files rather than using command-line flags for better maintainability.

Run as Service

Use systemd, launchd, or Windows services for automatic restarts and proper lifecycle management.

Regular Updates

Keep NATS Server updated to benefit from security patches and new features.

Monitor Logs

Configure proper logging and monitor logs for errors and performance issues.

Troubleshooting

Binary Not Found

Ensure the binary is in your PATH:
which nats-server
# If not found, add to PATH:
export PATH=$PATH:/usr/local/bin

Permission Denied

chmod +x /usr/local/bin/nats-server

Port Already in Use

Check what’s using port 4222:
sudo lsof -i :4222
# or
sudo netstat -tulpn | grep 4222

Service Won’t Start

Check service logs:
# systemd
sudo journalctl -u nats-server -f

# macOS
log show --predicate 'process == "nats-server"' --last 1h

Next Steps

Configuration

Learn about configuration options and best practices

Docker Deployment

Explore containerized deployment options

Build docs developers (and LLMs) love