Mongodb unable to connect to cluster - mongodb

We are using mongodb community addition .
We are able to connect to independent nodes primary, and 2 replicas using direct connection.
But when we try to connect to replica set using url:-
mongodb://sorterapp:SorTErRwXpressXb#3.109.226.31:27017,15.207.33.131:27017,13.234.13.53:27017/?authSource=sorter&replicaSet=stagesorter
It is not able to connect.
Error:-
getaddrinfo ENOTFOUND primary
Not sure what is the error
We tried using mongo compass as well as application library

Related

Error while connecting MongoDB ATLAS TO MONGO DB COMPASS

I am a beginer in mongoDB and learning Mongodb atlas.
In MongoDB Atlas, Under database access created username and password ( password is system generated and has no special character)
Under Network access added a public ip address (allow access from anywhere)
Under database deployment loaded sample database.
Now I wanted to see my cluster data, so wanted to connect it to vs code or MongoDB Compass. I clicked connect, selected connect using mongo db compass, copied the string.
now i opened Mongodb compass, and under New connection i.e connect to a MongoDB deployment, i entered my URL
mongodb+srv://gourav_singh:7gamf8UkL8B6MET#cluster0.9dmds.mongodb.net/test
clicked Connect
But i got error as : Unable to connect: connect ECONNREFUSED 3.6.85.199:27017
How I can fix it, Looking for kind help. Thanks in advance

When I execute rs.initiate() in Mongo DB its successful but compass gives connection error

I want to create a MongoDB 5.0 replica set on AWS EC2, When I create a standalone setup, it works completely fine. I can easily connect from anywhere. But when I convert this instance to a replica set with updating the mongod.conf and executing rs.initiate(), I cannot connect anymore!
My Mongo Compass gives the following error: getaddrinfo ENOTFOUND ip-172-31-14-219.eu-central-1.compute.internal

Not able to connect replica set of mongo DB in mongo-kafka source connect

Am using mongo kafka source connector v1.6.. Am trying to connect it replica set of mongo db
I have connection uri like this
mongodb://:#instance1:27017,instance2:27017,instance3:27017/?authSource=test&replicaSet=replicaset&ssl=true
the error am getting is
unable to connect server
... username and password is crct and also connectivity to DB also open
can u please tell what am doing wrong

mongodb how to get the correct uri

I've inherited node.js, mongodb system.
The original dev used a mlab db on his own account, I was asked to copy to a different db.
When I tried to create a mlab user I was redirected to cloud.mongodb.com (which apparently purchase mlab)
I was struggling to create a DB and connect to it through robo 3t and Compass, and now I'm able to connect and query the DB.
I used Compass export/import collection to copy the DB (was not able to copy in any other way)
Now I set the db uri in my app to the new db but it hangs when I do findOne
here is the old uri:
mongodb://dekel:password#ds115094.mlab.com:15094/somebuddy
therefore I assumed the connection string should be:
mongodb://root:password#cluster0-shard-00-00-jjbdh.mongodb.net:27017/somebuddy
I get
UnhandledPromiseRejectionWarning: MongoNetworkError: connection 0 to cluster0-shard-00-00-jjbdh.mongodb.net:27017 closed
when I connect with robo 3t I have to set the Database to admin other wise I get: Network is unreachable.
therefore I tried the following
mongodb://root:password#cluster0-shard-00-00-jjbdh.mongodb.net:27017/admin
I get:
MongoNetworkError: connection 0 to cluster0-shard-00-00-jjbdh.mongodb.net:27017 closed
The Mongodb site says that the connection string should be
mongodb+srv://root:<password>#cluster0-shard-00-00-jjbdh.mongodb.net/test?retryWrites=true
This is very strange since cluster0-shard-00-00-jjbdh.mongodb.net doesn't work on robo 3t and Compass, so I guess it is only an example.
I tired the following
mongodb+srv://root:password#cluster0-shard-00-00-jjbdh.mongodb.net:27017/somebuddy
I get:
Error: querySrv ENOTFOUND _mongodb._tcp.cluster0-shard-00-00-jjbdh.mongodb.net
I tried with the following different users
when I tried to use the chat on the mongodb website I get:
The team will get back to you on this. MongoDB Cloud Chat will be back tomorrow.
this is what I get when i try to connect with the shell (see https://www.youtube.com/watch?v=Ej05tq1220A):
C:\Program Files\MongoDB\Server\4.0\bin> .\mongo.exe "mongodb+srv://cluster0-jjbdh.mongodb.net/test" --username root
MongoDB shell version v4.0.8
Enter password:
connecting to: mongodb://cluster0-shard-00-01-jjbdh.mongodb.net.:27017,cluster0-shard-00-02-jjbdh.mongodb.net.:27017,cluster0-shard-00-00-jjbdh.mongodb.net.:27017/test?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true
2019-04-07T19:03:46.945+0300 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-01-jjbdh.mongodb.net.:27017,cluster0-shard-00-02-jjbdh.mongodb.net.:27017,cluster0-shard-00-00-jjbdh.mongodb.net.:27017
2019-04-07T19:03:58.840+0300 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-04-07T19:03:58.841+0300 I NETWORK [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2019-04-07T19:04:00.281+0300 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-04-07T19:04:00.282+0300 I NETWORK [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
2019-04-07T19:04:01.751+0300 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-04-07T19:04:01.752+0300 I NETWORK [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 3 checks in a row.
2019-04-07T19:04:01.756+0300 E QUERY [js] Error: connect failed to replica set Cluster0-shard-0/cluster0-shard-00-01-jjbdh.mongodb.net.:27017,cluster0-shard-00-02-jjbdh.mongodb.net.:27017,cluster0-shard-00-00-jjbdh.mongodb.net.:27017 :
connect#src/mongo/shell/mongo.js:343:13
#(connect):2:6
exception: connect failed
and
.\mongo.exe "mongodb://root:password#cluster0-shard-00-00-jjbdh.mongodb.net:27017/admin"
MongoDB shell version v4.0.8
connecting to: mongodb://cluster0-shard-00-00-jjbdh.mongodb.net:27017/admin?gssapiServiceName=mongodb
2019-04-07T19:17:19.420+0300 E QUERY [js] Error: network error while attempting to run command 'isMaster' on host 'cluster0-shard-00-00-jjbdh.mongodb.net:27017' :
connect#src/mongo/shell/mongo.js:343:13
#(connect):2:6
exception: connect failed
The correct uri was
mongodb+srv://root:password#cluster0-jjbdh.mongodb.net/somebuddy?retryWrites=true
which is actually almost the uri suggested by atlas:
mongodb+srv://root:<password>#cluster0-jjbdh.mongodb.net/test?retryWrites=true

Mongo DB BI Connector with Tableau not working with sharded instance

I've been trying to follow these instructions https://onlinehelp.tableau.com/current/pro/desktop/en-us/examples_mongodb.html#make_cx
to get the tableau desktop to connect to my mongo db server. looking at the data source example in the link above they only have 1 server listed where I have a replica set, which I think might be an issue.
i was wondering if anyone has an example connecting tableau to mongo where mongo is on a replica set?
It should work. When you setup the Mongo BI Connector, you can specify a standard Mongo URI connection string with multiple replicas. However, when connecting from Tableau, you specify the hostname of the server where the Mongo BI Connector service is running. It will use the uri connection string you defined.
See: https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#cmdoption-mongosqld-mongo-uri