mongodb - 错误:querySrv ESERVFAIL _mongodb._tcp.cluster0.abcd0.mongodb.net
问题描述
我的 nodejs 应用程序在 mongodb 连接上运行良好,突然出现了这个错误。然后我尝试使用 mongo compass 连接到 mongodb 并且存在同样的错误。我找不到任何原因。
Error: querySrv ESERVFAIL _mongodb._tcp.cluster0.abcd0.mongodb.net
[nodemon] app crashed - waiting for file changes before starting...
然后我将 mongodb 连接 url 更改为旧 url,之后我得到了这个错误。
Error: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/
[nodemon] app crashed - waiting for file changes before starting...
我已经将我的 ips 列入白名单并且我的配置是正确的(我仔细检查了)。0.0.0.0/0(包括您当前的 IP 地址)
这是什么原因?
谢谢你。
解决方案
querySrv ESERVFAIL
是 DNS 错误。
这意味着您的本地计算机无法从您的 DNS 解析器获得对 SRV 记录的响应_mongodb._tcp.cluster0.abcd0.mongodb.net
(我假设这不是您的真实主机名,但它可以作为示例)
在您的本地计算机上,从命令行测试 SRV 查找,可能是以下之一:
nslookup -type=SRV _mongodb._tcp.cluster0.abcd0.mongodb.net
host -t SRV _mongodb._tcp.cluster0.abcd0.mongodb.net
如果失败,请随意对您的 DNS 提供商说坏话。
然后转到 Atlas UI 并获取 3.6 之前的连接字符串。它将以mongodb://
and not开头mongodb+srv://
。
推荐阅读
- javascript - 如何在气泡图中按状态和在行/列中定位气泡
- php - 如何在对象中一次循环遍历 2 个或多个数组
- android - android中Google Docs预览中的RTL问题
- java - JTextPane 中的字体颜色同质性问题
- tensorflow - TensorFlow.js 无法在 Windows 10 中安装
- javascript - 为什么我无法从共享邮箱发送消息,即使删除了插件
- visual-studio-2015 - Visual Studio 2015 设计器不想显示表单 - 错误
- classification - 如何将数值类转换为 WEKA 中的因子?
- kubernetes - pod 网络错误
- java - 使用标志 CLEAR_TOP 时后台堆栈中的活动