HTTPfy

Port 27017 (MongoDB)

MongoDB server (mongod / mongos).

Registered (user) port, 1024-49151 TCP Databases Do not expose to the internet

What port 27017 is used for

MongoDB server (mongod / mongos).

Security: should port 27017 be open?

Do not expose to the internet. Never expose it without authentication. Tens of thousands of open MongoDB databases were wiped and held for ransom from 2017 on. Since 3.6 mongod binds to localhost by default; if you change bindIp, enable authorization and allow only app servers.

IANA assignment

Service nameProtoDescriptionAssigneeReference
mongodb TCP Mongo database system MongoDB Inc. -

Registry dates for this port: registered 2019-02-21.

Check what is listening on port 27017

Linux: is anything listening on TCP 27017?
sudo ss -tlnp 'sport = :27017'
Linux / macOS: which process owns the port
sudo lsof -nP -i :27017
Older Linux / BSD (net-tools)
sudo netstat -tlnp | grep ':27017 '
Windows (Command Prompt)
netstat -ano | findstr :27017
Windows (PowerShell)
Get-NetTCPConnection -LocalPort 27017 -State Listen | Select LocalAddress,OwningProcess

Test it from outside

From another machine
nc -vz -w 5 HOST 27017
From Windows
Test-NetConnection HOST -Port 27017

Block port 27017 in the firewall

ufw
sudo ufw deny 27017/tcp
iptables
sudo iptables -A INPUT -p tcp --dport 27017 -j DROP
nftables
sudo nft add rule inet filter input tcp dport 27017 drop
Windows Firewall
New-NetFirewallRule -DisplayName 'Block TCP 27017' -Direction Inbound -Protocol TCP -LocalPort 27017 -Action Block

Related ports

All port numbers · Open port checker
Assignment data: IANA port number registry (public domain), retrieved 2026-11-10.