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 (express - Can't connect to MongoDB Atlas (queryTxt ETIMEOUT) - Stack Overflow) 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)
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
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.
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();
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
@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.
There is no need to close & reopen Compass if you are trying resolve connection issues. I recommend starting with the troubleshooting documentation for Compass Connection Errors, which includes some suggestions for both Self-Hosted Environments and Atlas Clusters. There are some also more general suggestions on Error: couldn't connect to server 127.0.0.1:27017 - #16 by Stennie.
Since this discussion topic is almost two years old and software versions have changed, I have also closed the topic.