Port 4222 is the default NATS server client connection port. NATS is a lightweight, high-performance publish-subscribe messaging system. The NATS monitoring HTTP endpoint runs on port 8222. NATS Cluster routing uses port 6222. NATS is used in Kubernetes and microservice architectures as an alternative to Kafka and RabbitMQ for low-latency messaging.
Port Number
4222
Protocol
TCP
Service
NATS Messaging System
Range
IANA Registered (1024–49151)
Test NATS connectivity and server health
nats server check connection -s nats://host:4222NATS server stats – connections, messages in/out, bytes
curl http://host:8222/varzSubscribe to all subjects and print 5 messages (debugging)
nats sub -s nats://host:4222 '>' --count 5nats-sub -s nats://localhost:4222 '>'
nats pub -s nats://localhost:4222 greet 'hello'
curl http://localhost:8222/varzNATS was created by Derek Collison (founder of Synadia, previously TIBCO architect) in 2010. Originally written in Ruby, rewritten in Go for performance. NATS JetStream (persistent messaging) was added in 2021 as the built-in replacement for the deprecated NATS Streaming (stan).
NATS vs Kafka vs RabbitMQ?
NATS: lowest latency (~100us), simplest operations, ephemeral by default (JetStream for persistence). Kafka: highest throughput, durable by default, best for event sourcing/replay. RabbitMQ: richest routing (exchanges/bindings), best for complex message patterns and task queues. Choose by primary requirement: speed (NATS), durability (Kafka), routing (RabbitMQ).