Unable to connect to mongodb Atlas
See original GitHub issueHey, it works with local db but fails with mongodb atlas connection string, I’m using the syntax like this:
await client.connect(
"mongodb+srv://user:password@name.mongodb.net/db?authMechanism=SCRAM-SHA-1"
);
// also tried this
await client.connect(
"mongodb+srv://user:password@name.mongodb.net/db?retryWrites=true&w=majority&authMechanism=SCRAM-SHA-1"
);
// and this
await client.connect(
"mongodb+srv://user:password@name.mongodb.net/db?retryWrites=true&w=majority"
);
It always fails here: https://deno.land/x/mongo@v0.29.0/src/client.ts#L41 with error:
{
"ok":0,
"errmsg":"Authentication failed.",
"code":18,
"codeName":"AuthenticationFailed",
"$clusterTime":{"clusterTime":{"$timestamp":"7043035952079437828"},"signature":{"hash":"z8hkCMby/OYpTnJXHNS7+rZfBvI=","keyId":{"high":1625418439,"low":1,"unsigned":false}}},
"operationTime":{"$timestamp":"7043035952079437828"}
}
Can you share if it’s a known issue or do I need to provide some additional params?
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Can't connect to mongodb.Could not connect to any ...
First try to Allow Access From Anywhere. If it works it is most likely because you whitelisted an IP address that is not...
Read more >node.js - Error at connecting to MongoDb Atlas Server
I have had this issue connecting to a MongoDB Atlas cluster. I have had to resolve this ... Once I turned off my...
Read more >Can't connect to MongoDB atlas serverless instance
Hi, i have a MongoDB serverless instance but i can't connect to that. I am using the connection string that mongo atlas gives...
Read more >Cannot connect to MongoDB atlas
Hey guys. I recently deployed my app on Netlify and so far, everything is pretty good; however I cannot connect to my mongoDB...
Read more >Unable to connect to Mongo Atlas Cluster · Issue #6678
@ayukidawe I had this same issue for a month now. Since you are connecting to MongoAtlas, connect to your second or third node,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ah it seems the database name in the connection string isn’t supported for now. It started working once I’ve updated connection string like this:
The reason why I think it’s an issue is that the connection string I used works properly with nodejs mongo (official) driver and many users will use the same connections string and had the same issue.
I think
credential.dbshould not be changed unless there will be provided authSource explicitly.