Connection error
See original GitHub issueI am getting this error when I try to connect:
error: Uncaught (in promise) Error: MongoError: “Connection failed: Invalid hostname: ‘cluster0.gpkxo.mongodb.net?retryWrites=true&w=majority’”
throw new MongoError(Connection failed: ${e.message || e});
^
at MongoClient.connect (https://deno.land/x/mongo@v0.22.0/src/client.ts:93:15)
at async MongoDBConnector._makeConnection (https://deno.land/x/denodb@v1.0.38/lib/connectors/mongodb-connector.ts:44:7)
at async MongoDBConnector.query (https://deno.land/x/denodb@v1.0.38/lib/connectors/mongodb-connector.ts:65:5)
at async Database.query (https://deno.land/x/denodb@v1.0.38/lib/database.ts:240:21)
at async Function.createTable (https://deno.land/x/denodb@v1.0.38/lib/model.ts:172:5)
at async Database.sync (https://deno.land/x/denodb@v1.0.38/lib/database.ts:210:7)
I used the code example from the home page: db: ‘todo-app’, tls: true, servers: [ { host: ‘cluster0.gpkxo.mongodb.net?retryWrites=true&w=majority’, port: 27017, }, ], credential: { username: ‘<my_username>’, password: ‘<my_password>’, db: ‘todo-app’, mechanism: ‘SCRAM-SHA-1’, },
I also verified that the password was available by resetting and I made sure I had whitelisted my IP address.
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (6 by maintainers)

Top Related StackOverflow Question
What made it possible for me to connect via URI is adding the “authMechanism” param exactly like shown below. I also added it to the docs here a few weeks ago.
Thanks! This worked perfectly 💜