Port 9042 is Cassandra’s native CQL protocol, used by drivers and cqlsh to query the database. It should not be reachable from the public internet.
- Port
- 9042
- Protocol
- TCP
- Service
- Apache Cassandra (CQL)
- Expose to internet?
- No
- Also used by
- Cassandra, ScyllaDB, DataStax Enterprise
Is port 9042 safe to open?
Cassandra’s default AllowAllAuthenticator lets any client connect without a password, so an exposed node gives full read and write access to every keyspace. Exposed clusters have been wiped and held for ransom.
How to secure Apache Cassandra (CQL)
- Set
authenticator: PasswordAuthenticatorandauthorizer: CassandraAuthorizerin cassandra.yaml, then change the defaultcassandrasuperuser. - Set
rpc_addressto a private address and allow 9042 only from application servers. - Enable client-to-node encryption for traffic across networks.
Check if port 9042 is open
Linux: what is listening on this port
sudo ss -tlpn | grep ':9042 'Windows (PowerShell): what is listening
Get-NetTCPConnection -LocalPort 9042 -State Listen | Select-Object LocalAddress, OwningProcess, @{n='Process';e={(Get-Process -Id $_.OwningProcess).Name}}From another machine: is it reachable
nc -zv HOST 9042
# or
nmap -p 9042 HOST
# Windows
Test-NetConnection HOST -Port 9042Test the Apache Cassandra (CQL) service itself
cqlsh HOST 9042 -e "DESCRIBE CLUSTER"Restrict port 9042 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:9042:9042) 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 9042 proto tcp
sudo ufw deny 9042/tcpfirewalld: allow one source network only
sudo firewall-cmd --permanent --remove-port=9042/tcp
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/8" port port="9042" protocol="tcp" accept'
sudo firewall-cmd --reloadiptables
sudo iptables -A INPUT -p tcp --dport 9042 -s 10.0.0.0/8 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 9042 -j DROPWindows Firewall (PowerShell, as Administrator)
New-NetFirewallRule -DisplayName "Block 9042 from internet" -Direction Inbound -Protocol TCP -LocalPort 9042 -RemoteAddress Internet -Action BlockMonitor port 9042
Run a TCP port monitor against your public IP on port 9042: 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 7001 | Oracle WebLogic Server | High risk |
| Port 27017 | MongoDB | Critical risk |
| Port 9200 | Elasticsearch (HTTP API) | Critical risk |
FAQ
What is port 9042 used for?
Port 9042 is Cassandra’s native CQL protocol, used by drivers and cqlsh to query the database. It is also used by Cassandra, ScyllaDB, DataStax Enterprise.
Is it safe to open port 9042?
Not to the public internet. Cassandra’s default AllowAllAuthenticator lets any client connect without a password, so an exposed node gives full read and write access to every keyspace. Exposed clusters have been wiped and held for ransom.
Is port 9042 TCP or UDP?
Apache Cassandra (CQL) uses TCP on port 9042.
How do I check if port 9042 is open?
On the server, run sudo ss -tulpn | grep ':9042 ' (Linux) or Get-NetTCPConnection -LocalPort 9042 (Windows) to see what is listening. From another machine, run nc -zv HOST 9042 or Test-NetConnection HOST -Port 9042.
Know the moment a port stops answering.
TCP, HTTP, DNS and SSL checks from six regions, plus server metrics from a one-line agent.