Problem connecting to MongoDB Atlas

Hello,

I’m trying to connect to my MongoDB atlas cluster with Compass.

This is my uri: mongodb+srv://username:pswd@boursogame-9eaqw.mongodb.net/test?retryWrites=true&w=majority

But after 10s trying to connect, I get the error: querySrv ETIMEOUT _mongodb._tcp.boursogame-9eaqw.mongodb.net

I have found this solution on stack overflow (https://stackoverflow.com/questions/56334603/cant-connect-to-mongodb-atlas) wich worked for me, so here is my second uri that work for connecting via Compass : mongodb://username:pswd@boursogame-shard-00-00-9eaqw.mongodb.net:27017,boursogame-shard-00-01-9eaqw.mongodb.net:27017,boursogame-shard-00-02-9eaqw.mongodb.net:27017/test?ssl=true&replicaSet=ClusterMasjeed1-shard-0&authSource=admin&retryWrites=true

But now I want to connect via a nodejs application and I can’t make it work. I don’t really understand what I’m doing wrong. I tried on an other computer and I made it works easily with the first uri. Help?

Ps: All IP are whitelisted (0.0.0.0) and my port 27017 is open (tryed on portquiz.net:27017)

It looks like a wrong password since the three nodes

  1. boursogame-shard-00-00-9eaqw.mongodb.net
  2. boursogame-shard-00-01-9eaqw.mongodb.net
  3. boursogame-shard-00-02-9eaqw.mongodb.net

are alive.

I have double checked my usernames and password. Also, the uri work in Compass but doesn’t work in nodejs environnement, so it’s not an authentufication problem

None of the URI is working for me.

However if I connect without a username and password. I can connect. So I keep thinking that the user name username or the password pswd are not correct.

I can also see that

is not the appropriate replica set name for this cluster. I do not see the full name but it starts with Boursogame- which is normal given the hosts are named boursogame-….

well yes I didn’t gave the real username in the forum, but here is the real username and password: mongodb+srv://dbuser:dbuser@boursogame-9eaqw.mongodb.net/test?retryWrites=true&w=majority

I didn’t know we could connect without username/pswd. But I can’t connect with or without the password ^^. This is really weird because on other computers I can connect. Here is my code:

const {MongoClient} = require(‘mongodb’);
const uri = “mongodb+srv://dbuser:dbuser@boursogame-9eaqw.mongodb.net/test?retryWrites=true&w=majority”;

async function Main(){
let client = new MongoClient(uri);
await client.connect().then(()=> console.log(“DB connected”));

client.connection.on('error', function(error) {
console.error('Database connection error:', error);

});
}

Main();

The only thing I can see is a firewall or VPN issues.

I was able to connect and authenticate.

I would suggest that you change the role of dbuser to be readAndWrite on the test database only.

1 Like

I have tried deactivating windows firewall and avast. Also, I verified that my VPN wasn’t connected. I tried changing role of dbuser to read & write only but I still can’t connect to database

I have the exact same issue, checked my firewall and VPN and none of them are running.

Would really appreciate any additional help here. I’m working on an OSX machine.

@Sebastian_Alvarado Please start a new topic for your issue including relevant details of your environment such as the specific version of the driver/client you are trying to connect with and any error messages received.

Thanks,
Stennie