PortScan › Port guide › Port 27017
Port 27017 (MongoDB): Why Tens of Thousands of Databases Were Wiped in 2017
Port 27017 is the MongoDB default. In 2017 tens of thousands of unauthenticated instances were wiped, leaving ransom notes. bindIp and auth settings.
What is port 27017?
Port 27017 is MongoDB's default port. Starting with version 3.6, MongoDB's default bindIp changed to localhost, but servers on older versions or changed to bindIp: 0.0.0.0 are easily exposed to the internet without authentication.
When it is normally open
- Application servers connect to MongoDB on the internal network
Risks if it is open
Mass deletion and ransom demands
Starting in January 2017, several attack groups swept for unauthenticated MongoDB instances, deleted the data and left behind only a collection saying "send bitcoin and we'll give it back". Tens of thousands of databases were hit within a few weeks, and many had no backups.
Personal data leaks
Security researchers still keep finding exposed MongoDB instances containing member information.
Security checklist
- In
mongod.conf:net.bindIp: 127.0.0.1(add internal IPs if needed). - Turn on authentication:
security.authorization: enabled, then create an admin account. - In the firewall, allow 27017 only from application server IPs.
- In Docker use
-p 127.0.0.1:27017:27017; in the cloud, restrict with security groups. - Keep regular backups on a different server — it is the only real answer to ransom attacks.
How to check whether port 27017 is open
From outside (is it exposed to the internet?)
Whether your server or home router accepts port 27017 from the internet can only be confirmed by connecting from outside. A check from inside the same network bypasses the router's firewall and gives a different answer.
PortScan opens a real TCP connection from the Cloudflare edge and reports Open, Closed or Filtered. Members can scan every port on their own IP for free and other targets free once a day.
Check port 27017On the server (what is listening?)
Windows (PowerShell):
netstat -ano | findstr ":27017 "
Get-NetTCPConnection -LocalPort 27017 -State Listen | Select LocalAddress,OwningProcess
Linux:
sudo ss -tlnp | grep ':27017 '
If it listens on 0.0.0.0 or [::] it is open on every network; 127.0.0.1 means only that machine can connect. To test port 27017 on a server from another computer, use Test-NetConnection server-address -Port 27017 on Windows or nc -vz server-address 27017 on Linux and macOS.
How to close or restrict port 27017
The best fix is to turn the service off or make it listen only on 127.0.0.1 (see the checklist above). If you need the service but must keep it off the internet, use a firewall.
Windows Firewall
# Administrator PowerShell
New-NetFirewallRule -DisplayName "Block TCP 27017" -Direction Inbound -Protocol TCP -LocalPort 27017 -Action Block
# To allow a single IP instead (block rules take precedence, so use this instead of the rule above)
New-NetFirewallRule -DisplayName "Allow TCP 27017 from office" -Direction Inbound -Protocol TCP -LocalPort 27017 -RemoteAddress 203.0.113.10 -Action Allow
Linux (ufw)
sudo ufw deny 27017/tcp
# Allow a single IP only
sudo ufw allow from 203.0.113.10 to any port 27017 proto tcp
On a cloud server, also check port 27017 in the security group (inbound rules), which is separate from the OS firewall. For services running in Docker, the rules Docker creates can bypass ufw, so binding the port to localhost with -p 127.0.0.1:27017:27017 is the reliable option.
Router
At home or in a small office, open the router's admin page and check whether port 27017 is in the port forwarding list, whether DMZ is enabled, and whether any program opened ports by itself through UPnP. If any of the three applies, port 27017 on your PC is directly visible from the internet.
How to read the scan result
- Open — something accepted a connection on port 27017. Work through the risks above.
- Closed — the packet reached the device, but nothing is listening on that port, so it was refused immediately (RST). The service is off.
- Filtered — no response. A firewall or the ISP is dropping packets, or the device is off. From an exposure point of view this is the safest state.
The verdict can depend on where you connect from. Many ISPs (including most Korean ISPs) block some ports such as 135, 139 and 445 on their network, so the same server can look Filtered from inside that network and Closed from abroad.
FAQ
- Is MongoDB Atlas (cloud) at risk too?
- Atlas requires authentication by default and uses an IP access list. But if you add 0.0.0.0/0 to the access list, the same risk applies.
Related ports
Last updated 2026-11-04 · Use this guide to check systems you manage. Scanning systems without permission may carry legal liability.