← Back to all services
Databases

MongoDB Default Port & Configuration

mongodb systemctl: mongod

Document-oriented NoSQL database. Stores data in flexible JSON-like documents.

🔌 Default Ports

27017
tcp
MongoDB protocol
27018
tcp
Shard server
27019
tcp
Config server

📦 Installation Command

N/A - not in Ubuntu repos. Use MongoDB official repo.

⚙️ Configuration Files

  • /etc/mongod.conf

📂 Default Directories

  • config: /etc/mongod.conf
  • data: /var/lib/mongodb
  • logs: /var/log/mongodb

🔐 Default Credentials

Username:N/A (no auth by default)
Password:N/A (no auth by default)
💡 CRITICAL: MongoDB has NO authentication by default! Enable auth immediately: use admin; db.createUser({user:'admin',pwd:'password',roles:['root']}); Then set security.authorization: enabled in config

📌 Dependencies

libcurl4libgssapi-krb5-2libssl3

⚠️ Conflicts

N/A (unique port) Port: N/A

✅ Works With

nodejspythonphp-mongodb

🛡️ Security Notes

ALWAYS enable authentication, bind to localhost or specific IPs only, enable SSL/TLS, disable REST interface, use role-based access control

❓ Frequently Asked Questions

What port does MongoDB use?
MongoDB uses port 27017 by default for client connections.
Does MongoDB have default password?
No, MongoDB has no authentication by default. You must enable it manually for security.
How to enable MongoDB authentication?
Add security.authorization: enabled to mongod.conf and create admin user.