Skip to content
statance
MenuClose
← All ports

Port 2181: Apache ZooKeeper

High risk

Port 2181 is the ZooKeeper client port. Distributed systems such as older Kafka, HBase and SolrCloud use ZooKeeper to store configuration and coordinate leaders. It should not be reachable from the public internet.

Port
2181
Protocol
TCP
Service
Apache ZooKeeper
Expose to internet?
No
Also used by
Kafka (older versions), HBase, Solr, ClickHouse Keeper (2181 compatible)

Is port 2181 safe to open?

ZooKeeper allows unauthenticated access by default. Anyone who can connect can read cluster configuration, which sometimes includes credentials, and can change or delete znodes to break dependent services. Four-letter-word commands also reveal environment details.

How to secure Apache ZooKeeper

  • Allow 2181 only from the cluster members and clients that need it.
  • Enable SASL authentication and set ACLs on znodes.
  • Limit four-letter-word commands with 4lw.commands.whitelist (for example srvr, ruok).
  • Enable TLS on the client port for traffic between sites.

Check if port 2181 is open

Linux: what is listening on this port

sudo ss -tlpn | grep ':2181 '

Windows (PowerShell): what is listening

Get-NetTCPConnection -LocalPort 2181 -State Listen | Select-Object LocalAddress, OwningProcess, @{n='Process';e={(Get-Process -Id $_.OwningProcess).Name}}

From another machine: is it reachable

nc -zv HOST 2181 # or nmap -p 2181 HOST # Windows Test-NetConnection HOST -Port 2181

Test the Apache ZooKeeper service itself

echo srvr | nc HOST 2181

Restrict port 2181 in the firewall

Replace 10.0.0.0/8 with the network or address that needs access. Docker publishes container ports through its own iptables rules, which bypass ufw; bind published ports to 127.0.0.1 (-p 127.0.0.1:2181:2181) instead of relying on the host firewall.

ufw: allow only your private network, deny everyone else

sudo ufw allow from 10.0.0.0/8 to any port 2181 proto tcp sudo ufw deny 2181/tcp

firewalld: allow one source network only

sudo firewall-cmd --permanent --remove-port=2181/tcp sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/8" port port="2181" protocol="tcp" accept' sudo firewall-cmd --reload

iptables

sudo iptables -A INPUT -p tcp --dport 2181 -s 10.0.0.0/8 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 2181 -j DROP

Windows Firewall (PowerShell, as Administrator)

New-NetFirewallRule -DisplayName "Block 2181 from internet" -Direction Inbound -Protocol TCP -LocalPort 2181 -RemoteAddress Internet -Action Block

Monitor port 2181

Run a TCP port monitor against your public IP on port 2181: here, a failed connection is the healthy result, so you know the firewall is still doing its job. On Linux, the Statance agent also reports every listening port on the server. TCP port monitoring.

Related ports

Port 9092Apache KafkaHigh risk
Port 2379etcd (client API)Critical risk
Port 9042Apache Cassandra (CQL)High risk

FAQ

What is port 2181 used for?

Port 2181 is the ZooKeeper client port. Distributed systems such as older Kafka, HBase and SolrCloud use ZooKeeper to store configuration and coordinate leaders. It is also used by Kafka (older versions), HBase, Solr, ClickHouse Keeper (2181 compatible).

Is it safe to open port 2181?

Not to the public internet. ZooKeeper allows unauthenticated access by default. Anyone who can connect can read cluster configuration, which sometimes includes credentials, and can change or delete znodes to break dependent services. Four-letter-word commands also reveal environment details.

Is port 2181 TCP or UDP?

Apache ZooKeeper uses TCP on port 2181.

How do I check if port 2181 is open?

On the server, run sudo ss -tulpn | grep ':2181 ' (Linux) or Get-NetTCPConnection -LocalPort 2181 (Windows) to see what is listening. From another machine, run nc -zv HOST 2181 or Test-NetConnection HOST -Port 2181.

All ports →

Know the moment a port stops answering.

TCP, HTTP, DNS and SSL checks from six regions, plus server metrics from a one-line agent.