我的nodejs应用程序在mongodb连接上工作得很好,突然出现了这个错误。然后我尝试用mongo指南针连接到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地址)
这是什么原因呢?
谢谢。
发布于 2021-08-24 07:38:12
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://
而不是mongodb+srv://
开头。
https://stackoverflow.com/questions/68875026
复制相似问题