K
K
Kotik Meow2019-07-11 22:29:11
MongoDB
Kotik Meow, 2019-07-11 22:29:11

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' }

Source:
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));

Moreover, the same error (querySrv EREFUSED _mongodb._tcp.crf1-o7dqz.gcp.mongodb.net) appears when connecting to the MongoDB Compass database. What could be the reason for this and how to fix it? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Shevtsov, 2019-08-12
@phoenix2006

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

A
Andrey Chirkov, 2021-04-15
@andreichirkov

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 question

Ask a Question

731 491 924 answers to any question