Port 27017: MongoDB

Port 27017 (TCP) is used by MongoDB. Default MongoDB port. Bind to localhost and enable auth (unofficial use).

27017Port
TCPProtocol
—IANA service name
DatabasesCategory

Port range

27017 is a registered port (range 1024–49151). Any user can bind to it; IANA records which service registered the number.

Security

Port 27017 should not be reachable from the public internet. Restrict it to trusted networks or a VPN, and scan your public IP to confirm it is closed.

Open port 27017 in a firewall

ufw         sudo ufw allow 27017/tcp
iptables    sudo iptables -A INPUT -p tcp --dport 27017 -j ACCEPT
firewalld   sudo firewall-cmd --permanent --add-port=27017/tcp
Windows     New-NetFirewallRule -DisplayName "MongoDB 27017" -Direction Inbound -Protocol TCP -LocalPort 27017 -Action Allow

Check if port 27017 is open

nc -vz example.com 27017
Test-NetConnection example.com -Port 27017   # PowerShell
sudo ss -tulpn | grep ':27017 '   # what is listening locally (Linux)

Other databases ports

Frequently asked questions

What is port 27017 used for?
MongoDB. Default MongoDB port. Bind to localhost and enable auth (unofficial use).
Is port 27017 TCP or UDP?
TCP.