Did you mean to connect to: mongodb://localhost:27017?
Port 27017 is for MongoDB database connections. Use mongo shell or your application driver to connect.
sudo systemctl status mongod (Linux)brew services list | grep mongodb (Mac)tasklist | findstr mongod (Windows)
mongo (Legacy shell)mongosh (New shell)mongo mongodb://localhost:27017/database
lsof -i :27017 (Mac/Linux)netstat -ano | findstr :27017 (Windows)
sudo systemctl start mongod (Linux)brew services start mongodb-community (Mac)net start MongoDB (Windows)
Port 27017 is the default port for:
MongoDB server is not running or not accessible:
sudo systemctl start mongodmongod --versionnetstat -tlnp | grep 27017sudo tail -f /var/log/mongodb/mongod.logmongod --dbpath /data/dbAuthentication error when connecting to MongoDB:
mongo --authenticationDatabase adminuse admin
db.createUser({
user: "admin",
pwd: "password",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
})
mongo -u admin -p password --authenticationDatabase adminMongoDB data directory doesn't exist:
sudo mkdir -p /data/dbsudo chown -R mongodb:mongodb /data/dbmongod --dbpath /custom/pathAnother process is using MongoDB's port:
lsof -i :27017sudo systemctl stop mongodsudo kill -9 PIDnet: port: 27018
sudo systemctl restart mongodNetwork connectivity issues with MongoDB:
bindIp: 127.0.0.1telnet localhost 27017bindIp: 0.0.0.0ping localhost