9951 explained code solutions for 126 technologies

mongodbWhat is MongoDB default port?

MongoDB default port is 27017. It is the port on which MongoDB server listens for client connections.

Example code to connect to MongoDB server on default port:

mongo --host --port 27017

Output of the above code:

MongoDB shell version v4.2.3
connecting to: mongodb://
Implicit session: session { "id" : UUID("f9f9f9f9-f9f9-f9f9-f9f9-f9f9f9f9f9f9") }
MongoDB server version: 4.2.3

The code above connects to MongoDB server running on (localhost) on port 27017.

Helpful links

Edit this code on GitHub