Port 27017 is the default MongoDB port. MongoDB has a history of security incidents from exposed instances – in 2017 over 28,000 publicly accessible MongoDB databases were held ransom. MongoDB should bind to 127.0.0.1 and use authentication. MongoDB Atlas handles this automatically.
Port Number
27017
Protocol
TCP
Service
MongoDB Database
Range
IANA Registered (1024–49151)
Test connectivity and auth status
mongosh --host host --port 27017 --eval 'db.runCommand({connectionStatus:1})'Remote MongoDB detection and version fingerprinting
nmap -sV -p 27017 --script mongodb-info targetCheck which auth mechanisms are enabled
mongosh --eval 'db.adminCommand({getParameter:1, authenticationMechanisms:1})'mongosh --host localhost --port 27017
mongosh 'mongodb://user:pass@localhost:27017/db'
mongodump --host localhost --port 27017MongoDB was created by 10gen (now MongoDB Inc) in 2009. Port 27017 was chosen arbitrarily. The name comes from 'humongous'. Version 3.6 (2017) changed the default bind to localhost after the 2017 mass-ransom incident. Version 6.0 (2022) added queryable encryption.
Is MongoDB still insecure by default?
Since version 3.6 (2017), MongoDB binds to localhost only and enables authentication by default in the official Docker image. But self-compiled or older package installs may still default to open. Always verify: mongosh --eval 'db.adminCommand({getParameter:1,"authenticationMechanisms":1})'.
MongoDB Atlas vs self-hosted security?
Atlas enforces authentication, encryption at rest, TLS in transit, and IP allowlisting by default. Self-hosted requires you to configure all of these manually. For teams without dedicated DBAs, Atlas eliminates the most common MongoDB security mistakes.