本文介绍了错误:使用猫鼬连接到 MongoDb Atlas 时出现 queryTxt ETIMEOUT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的猫鼬与我的 MongoDB Atlas 集群连接起来.它目前没有数据库或任何东西,但每当我尝试时:

mongoose.connect( uri || 'mongodb://localhost/test',options).then(()=>{console.log("连接到数据库.Yayzow!");}).catch(错误 => {控制台日志(错误);});

我收到这条消息:

错误:queryTxt ETIMEOUT cluster0-ghis2.mongodb.net在 QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19) {errno: 'ETIMEOUT',代码:'ETIMEOUT',系统调用:'queryTxt',主机名:'cluster0-ghis2.mongodb.net'}

我的依赖:

 "依赖项": {"快递": "^4.17.1","mongodb": "^3.5.7",猫鼬":^5.9.14"}

我现在已将所有 IP 列入白名单 (0.0.0.0/0).此外,我已确保我的防火墙已断开连接,我的防病毒软件也是如此.我也让我的朋友检查了它,它确实对他有用,但对我无效

感谢任何帮助!

编辑

通过将我的 DNS 更改为 Google 的公共 DNS 解决了错误!如果有人收到此错误,请确保更改您的 DNS.在

Im trying to connect my mongoose with my MongoDB Atlas Cluster. It currently has no database or anything but whenever I try:

mongoose.connect( uri || 'mongodb://localhost/test',options)
.then(()=>{
    console.log("Connected to the Database. Yayzow!");
})
.catch(err => {
    console.log(err);
});

I get this message:

Error: queryTxt ETIMEOUT cluster0-ghis2.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19) {
errno: 'ETIMEOUT',
  code: 'ETIMEOUT',
  syscall: 'queryTxt',
  hostname: 'cluster0-ghis2.mongodb.net'
}

My dependencies:

  "dependencies": {
    "express": "^4.17.1",
    "mongodb": "^3.5.7",
    "mongoose": "^5.9.14"
  }

I've whitelisted all IPs as off now (0.0.0.0/0). Also I've made sure my firewall is disconnected and so is my anti-virus. I made my friend check it out too and it did work for him but not me

Any help is appreciated!

EDIT

Solved the error by changing my DNS to Google's Public DNS!If anyone get this error just make sure to change your DNS.Throwing a link for the same here

解决方案

The error because of the version of you node and npm,to remove this error you just need to change you connection String by going to Connect and connect to Application

  1. change the version to 2.2.122 or later
  2. copy String and paste then try to connect it again.as shown in Picture

这篇关于错误:使用猫鼬连接到 MongoDb Atlas 时出现 queryTxt ETIMEOUT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 11:41