`Problem connecting mongoDB Atlas?
D
D
Denioo2019-09-26 16:57:50
MongoDB
Denioo, 2019-09-26 16:57:50

Problem connecting mongoDB Atlas?

Good afternoon, there was a problem connecting to MongoDBAtlas. When I try to connect via

try{   
    const url = `mongodb+srv://denioo:<password>@cluster0-cn3cp.mongodb.net/test?retryWrites=true&w=majority`

    await mongoose.connect(url, {useNewUrlParser: true})

    app.listen(PORT, () => {
        console.log(`Server is running on port ${PORT}`)
    })
    }catch(e){
        console.log(e)
    }

I inserted my pass into the place.
Then an error occurs:
Error: queryTxt EREFUSED cluster0-cn3cp.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19) {
  errno: 'EREFUSED',
  code: 'EREFUSED',
  syscall: 'queryTxt',
  hostname: 'cluster0-cn3cp.mongodb.net'
}

At first I thought that the brandmauer was to blame, turned it off. Then I thought the problem was in the dynamic IP, I made the connection open from any IP. But nothing helps, still the same error crashes.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mike_Zhukovskiy, 2019-10-09
@Mike_Zhukovskiy

I was able to connect via driver version 2.2.12
, the connection string looks like this:

mongodb://username:<password>@cluster0-shards-00-00-jipa1.mongodb.net:27017,cluster0-shards-00-01-jipa1.mongodb.net:27017,cluster0-shards-00-02-jipa1.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true&w=majority

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question