Skip to main content
PORT 27017 / TCPDatabase & CacheExposure Risk: Critical

Port 27017: MongoDB — MongoDB NoSQL Database Server (mongod)

Default port for MongoDB database instances and mongos routers. Enforce authentication and bind to localhost/VPC.

Default Service
MongoDB
Process: mongod
Transport Protocol
TCP
IANA Registered Port 27017
Docker Port Flag
-p 27017:27017
Container to Host Mapping

How to Check & Kill Process on Port 27017 (EADDRINUSE Fix)

macOS & Linux (lsof / kill)
# Find process using port 27017
sudo lsof -i :27017

# Instantly kill process on port 27017
lsof -ti:27017 | xargs kill -9
Windows (PowerShell & CMD)
# Find PID listening on port 27017
netstat -ano | findstr :27017

# Force kill by PID
taskkill /PID <PID_NUMBER> /F
Cross-Platform Node.js One-Liner
# Kill port 27017 via npx
npx kill-port 27017

# Or diagnose via Castov CLI
npx castov fix "EADDRINUSE :::27017"
Linux Firewall (UFW) & Connectivity Test
# Test if port 27017 is reachable
nc -zv localhost 27017

# Allow or deny port 27017 in UFW
sudo ufw allow 27017/tcp

Frequently Asked Questions about Port 27017

What is Port 27017 used for?

Port 27017 is the standard network port for MongoDB (MongoDB NoSQL Database Server (mongod)) operating over TCP. The typical system daemon or process is mongod.

How do I kill a process running on Port 27017 (EADDRINUSE)?

On macOS and Linux, run: lsof -ti:27017 | xargs kill -9 (or npx kill-port 27017). On Windows PowerShell/CMD, run: netstat -ano | findstr :27017 and then taskkill /PID <PID> /F.

Is it safe to expose Port 27017 to the internet?

Port 27017 has a Critical security risk profile. Default port for MongoDB database instances and mongos routers. Enforce authentication and bind to localhost/VPC.

Other Common Network Ports