Prerequisites
No special prerequisites are required. NATS Server is a single binary with no external dependencies.Get started
Install NATS Server
The fastest way to get started is using Docker:Alternatively, download the binary for your platform from the GitHub releases page.For other installation methods, see the installation guide.
Start the server
Start NATS Server with default settings:You should see output indicating the server is running:
The default client port is 4222. The monitoring port is 8222 when enabled with
-m 8222.Install the NATS CLI (optional)
For testing, install the NATS CLI tool:The NATS CLI is also included in the Docker image at
/bin/nats.Subscribe to a subject
Open a new terminal and subscribe to a test subject:You should see:Leave this terminal open to receive messages.
Publish a message
In another terminal, publish a message:In the subscriber terminal, you should see the message:
Common server options
Here are some commonly used command-line options:For a complete list of options, run
nats-server --help or see the configuration reference.Testing with client libraries
NATS has client libraries for over 40 programming languages. Here’s a quick example in a few popular languages:Next steps
Now that you have NATS Server running, explore these topics:Configuration
Learn how to configure NATS Server for production
JetStream
Enable persistence and streaming with JetStream
Clustering
Set up high availability with clustering
Security
Secure your NATS deployment
Troubleshooting
Connection refused errors
Connection refused errors
Ensure the server is running and listening on the correct port (default 4222). Check firewall settings if connecting from a different machine.
Server won't start
Server won't start
Check if another process is using port 4222. Use
nats-server -p 4223 to use a different port. Enable debug logging with -D for more information.Messages not being received
Messages not being received
Verify the subscriber is connected before publishing. Check that subject names match exactly (they are case-sensitive).
Get help
If you need assistance:- Join the NATS Community Slack
- Ask questions on Google Groups
- Check the FAQ