What uri should i use I have added 0.0.0.0 in network so that its accessible publicly

I am on windows cmd

the uri I am using is - mongodb://myusername:mypassword@cluster0.ikhum.mongodb.net:27017/test?authSource=admin

I am getting this error

[nodemon] starting `node ./src/index.js`
server started on port 3000 (development)
MongoDB connection error: MongoError: failed to connect to server [cluster0.ikhum.mongodb.net:27017] on first connect [Error: getaddrinfo ENOTFOUND cluster0.ikhum.mongodb.net
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26) {
  name: 'MongoError',
  message: 'getaddrinfo ENOTFOUND cluster0.ikhum.mongodb.net'
}]

What should I do

Can you connect by shell?

From your Atlas account you can get the connect string for your app node.js
Something like below:

mongodb+srv://:@cluster0.xyz.mongodb.net/myFirstDatabase?retryWrites=true&w=majority

Replace mongodb:// in your URI with mongodb+srv://.

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.