question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I 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:open
  • Created 2 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
RNR1commented, Jun 20, 2021

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.

await client.connect(
  "mongodb+srv://<username>:<password>@<db_cluster_url>/<db_name>?authMechanism=SCRAM-SHA-1",
);
0reactions
toridorivcommented, Oct 21, 2022

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.

await client.connect(
  "mongodb+srv://<username>:<password>@<db_cluster_url>/<db_name>?authMechanism=SCRAM-SHA-1",
);

Thanks! This worked perfectly 💜

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix connection errors - Google Chrome Help
Fix most connection errors. If you go to a website and get an error, try these troubleshooting steps first: Check the web address...
Read more >
Connection Errors
Connection errors can occur for a variety of reasons. For example, a failure in any of the internal connections described in How Connection...
Read more >
How to Fix the ERR_CONNECTION_RESET Error in 7 Ways
The ERR_CONNECTION_RESET error message means that your browser has failed to establish a connection with the webserver. To put it simply, the website...
Read more >
How to Fix the "ERR_CONNECTION_RESET" Error (5 Ways)
Learn how to fix the "ERR_CONNECTION_RESET" error code that displays in Google Chrome because there was a failed connection.
Read more >
My browser shows a "No network connection" error - HTC
When using your browser, you may receive the error "‍No network connection - The page will continue loading after connection has been restored"‍....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found