mongo: Couldn’t connect with atlas database
when I tried to connect to an atlas database using:
import { MongoClient } from "https://deno.land/x/mongo@v0.21.0/mod.ts";
const client = new MongoClient();
await client.connect(
"mongodb+srv://Eyoatam:" +
Deno.env.get("MONGO_ATLAS_PASSWORD") +
"@cluster0.xrb4d.mongodb.net/<dbname>?retryWrites=true&w=majority"
);
It threw the following error:
error: Uncaught (in promise) Error: failed to lookup address information: nodename nor servname provided, or not known
at processResponse (deno:core/core.js:223:11)
at Object.jsonOpAsync (deno:core/core.js:240:12)
at async Object.connect (deno:cli/rt/30_net.js:224:13)
at async MongoClient.connect (client.ts:41:14)
at async app.ts:4:1
is there another way to connect with mongodb atlas?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 23 (7 by maintainers)
Hi everyone, I was trying to connect to the Atlas database. I have tried all the possible solutions above. finally, I can connect with this way
You should set your primary cluster address to host. After that, It should connect successfully. I think you are getting an error while finding objects.
Can you try this? It works for me.