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 examplesrvr, 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 2181Test the Apache ZooKeeper service itself
echo srvr | nc HOST 2181Restrict 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/tcpfirewalld: 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 --reloadiptables
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 DROPWindows Firewall (PowerShell, as Administrator)
New-NetFirewallRule -DisplayName "Block 2181 from internet" -Direction Inbound -Protocol TCP -LocalPort 2181 -RemoteAddress Internet -Action BlockMonitor 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 9092 | Apache Kafka | High risk |
| Port 2379 | etcd (client API) | Critical risk |
| Port 9042 | Apache 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.
Know the moment a port stops answering.
TCP, HTTP, DNS and SSL checks from six regions, plus server metrics from a one-line agent.