MongoDB server setup on Azure VM Linux machine

MRvLuijpen
MongoDB server setup on Azure VM Linux machine

Hello Community, 

I am experimenting a bit with all kinds of data connections (MS SQL Server, MySQL, PostgreSQL, Snowflake) and have set up a MongoDB Server running on the same Azure machine as my DSS is running. A database and user are set up on the MongoDB, but a connection towards the MongoDB results in the following time out error :

Connection failed: Could not connect to server: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=##.##.##.##:####, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]

Hope someone can help me with this.

Thanks in advance

Marc Robert

And perhaps this can be also be added to the course https://academy.dataiku.com/integration-with-mongodb 

0 Kudos
6 Replies
NicolasM
Dataiker

Hi Marc,

By default MongoDB only accepts connection from localhost. As both your DSS and MongoDB are on the same instance, did you try connecting with localhost rather than with your ##.##.##.## address?

0 Kudos
MRvLuijpen
Author

Hello @NicolasM , 

I tried that as well, and this also resulted in an error :

 Connection failed: Could not connect to server: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='#####', source='#####', password=<hidden>, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server localhost:####. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }}}]

 

0 Kudos
MRvLuijpen
Author

In addition to the last message, I was able to connect to the MongoDB with VS Code on the Linux machine with the user & password. Might the Azure cause the connecting problem?

0 Kudos
NicolasM
Dataiker

This error message is different, and the good news is that DSS can now reach the database but you have an authentication issue.

Can you double check the details (database name, user and password) that you entered in the connection?

0 Kudos
MRvLuijpen
Author

Hello  @NicolasM

I have checked several times that I am using the same user id & password, without success.๐Ÿ˜ข 

0 Kudos
NicolasM
Dataiker

Did you try to connect from the mongo shell rather than from DSS to your MongoDB server? (see https://docs.mongodb.com/manual/mongo/)

Also I would try to create another user/password and try to connect with this one.

0 Kudos