1
votes

I've followed this guide to get my MongoDB server externally-facing:

https://ianlondon.github.io/blog/mongodb-auth/

but when I try to connect to it using: mongo -u myusername -p mypassword myip/mycollection (myip is the public ip of my azure vm. Yes, i've added the inbound rule)

I get:

Error: network error while attempting to run command 'isMaster' on host 'myip:27017' : connect@src/mongo/shell/mongo.js:251:13

Details: Server: Azure vm, Ubuntu 18.04, Mongo 3.6.7 Client: vmware vm, Ubuntu 18.04, Mongo 3.6.7

I have not enabled ssh (that I'm aware of?), as other posts have suggested.

Any ideas?

2

2 Answers

2
votes

Worked it out. I guess Ian's guide is out of date; I had to set the bindIp configuration item to 0.0.0.0, rather than commenting it out.

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0
0
votes

You can add one more parameter to your mongo shell command i.e

--authenticationDatabase *databaseName*

It is the database name against which you have created your user. According to the link you have provided which you have followed to get your setup running, the value to be used will be cool_db.

Basically, this error occurs when mongo is unable to reach out the server. Please refer to https://docs.mongodb.com/tutorials/connect-to-mongodb-shell/ documentation.

If you are new to MongoDB, I will highly recommend you joining the basic MongoDB course which is roughly 1 week course to get you running. [https://university.mongodb.com]

I hope it helps.

Thanks, Kanika