Port 27017: MongoDB

Port 27017 is the default MongoDB listener. Unsecured MongoDB on this port has caused many data leaks, so enable auth and keep it off the public internet.

TCPDatabasesUnencrypted by defaultIANA assigned
Port number27017
ServiceMongoDB database
ProtocolTCP
CategoryDatabases
Default encryptionNo
Security note. Port 27017 is not encrypted by default. Restrict it to trusted networks, or use an encrypted alternative where one exists, to avoid exposing credentials and data in transit.

How do I check whether port 27017 is open?

Port 27017 carries TCP, so a connection either completes its handshake or it does not, which makes the check definitive.

QuestionCommandWhat to know
Is it open on a remote host?nc -vz example.com 27017A TCP handshake either completes or it does not, so netcat gives a definitive answer in one line.
Same check on WindowsTest-NetConnection example.com -Port 27017Built into PowerShell. TcpTestSucceeded in the output is the answer; telnet is not installed by default on modern Windows.
What is listening locally?ss -tlnp | grep ':27017 'Lists the process bound to port 27017 on Linux. On macOS use lsof -nP -iTCP:27017 -sTCP:LISTEN, on Windows netstat -ano | findstr :27017

Replace example.com with the host you are testing. A blocked port and a port with nothing listening on it look identical from the outside, so if a service should be running, check locally before blaming the firewall.

Frequently asked questions

What is port 27017 used for?

Port 27017 is the default MongoDB listener. Unsecured MongoDB on this port has caused many data leaks, so enable auth and keep it off the public internet.

Is port 27017 TCP or UDP?

Port 27017 (MongoDB) uses TCP.

Is port 27017 secure?

Port 27017 is not encrypted by default. Where possible, use an encrypted alternative or tunnel it over TLS or a VPN.

Should I open port 27017 on my firewall?

Only if you specifically need MongoDB. Expose it to the smallest set of trusted sources, and never open database or Windows-service ports to the whole internet.