localhost:27017

Port 27017 is MongoDB — the popular NoSQL document database. Store JSON-like documents, scale horizontally, query with powerful aggregations. MERN stack developers live on this port.

Connect to MongoDB

MongoDB Shell (mongosh)

# Connect locally
mongosh

# Or specify connection
mongosh "mongodb://localhost:27017"

# Connect to specific database
mongosh "mongodb://localhost:27017/mydb"

# With authentication
mongosh "mongodb://user:pass@localhost:27017/mydb"

Connection Strings

# Standard URI
mongodb://localhost:27017/mydb

# Node.js (Mongoose)
mongoose.connect('mongodb://localhost:27017/mydb');

# Python (PyMongo)
client = MongoClient('mongodb://localhost:27017/')

# PHP
$client = new MongoDB\Client("mongodb://localhost:27017");

Check if MongoDB is Running

# Linux
sudo systemctl status mongod

# Mac (Homebrew)
brew services list | grep mongodb

# Test connection
mongosh --eval "db.runCommand({ping:1})"

Common Errors

ErrorSolution
Connection refusedMongoDB not running. Start mongod service.
Authentication failedCheck username/password and authSource
Network timeoutCheck firewall, verify bindIp setting

Start MongoDB

# Linux
sudo systemctl start mongod

# Mac
brew services start mongodb-community

# Docker
docker run -d -p 27017:27017 mongo

# Manual
mongod --dbpath /data/db

MongoDB Compass

GUI tool for MongoDB. Connect using:

mongodb://localhost:27017

Related Ports

PortDatabase
3306MySQL
5432PostgreSQL
6379Redis