Thursday, 3 August 2023

MongoDB Host and Port

 Get the detail of mongodb Host and mongodb runing on which port fo you get all these type of info from mongo shell.

getHostName(); # Hostname info

db.serverCmdLineOpts(); # Port info
db.serverCmdLineOpts().parsed.net.port

db.runCommand({whatsmyuri : 1}) # Its is showing both Hostname and Port

No comments: