Answer the question
In order to leave comments, you need to log in
How to get rid of querySrv EREFUSED _mongodb._tcp.crf1-o7dqz.gcp.mongodb.net error when connecting to MongoDB Atlas?
When connecting to MongoDB, Atlas throws an error:
{ Error: querySrv EREFUSED _mongodb._tcp.crf1-o7dqz.gcp.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (dns.js:196:19)
errno: 'EREFUSED',
code: 'EREFUSED',
syscall: 'querySrv',
hostname: '_mongodb._tcp.crf1-o7dqz.gcp.mongodb.net' }
const mongoose = require('mongoose');
mongoose.connect('mongodb+srv://UserName:[email protected]/test?retryWrites=true&w=majority',
{ useNewUrlParser: true })
.then(() => console.log('Database connected'))
.catch(e => console.log(e));
Answer the question
In order to leave comments, you need to log in
Greetings! Had the same error recently.
- in connect check that the promise is processed correctly.
- you need to choose a line for connection depending on the version of the node. This is provided in the mongo-atlas. most likely you chose a more recent version of the node.
- try with temporarily disabled avpo
Everything I read on the Internet to solve the problem did not help
I solved the problem by recreating the project with servers in America (I decided to try it in Germany initially)
Then, for the sake of verification, I created it again with German ones - it does not work
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question