无法将 atlas 服务器连接到 mongo shell

时间:2021-06-17 04:29:30

标签: node.js mongodb mongodb-atlas

我对 mongodb 和 atlas 很陌生。我正在尝试在学习 Web 开发时将我的 atlas 服务器连接到 mongo shell。我正在尝试运行命令:

mongo "mongodb+srv://cluster0.6ss5b.mongodb.net/myFirstDatabase" --username Bruno

如果我在没有 vpn 的情况下在互联网上运行,我会收到错误:

DNSHostNotFound: Failed to look up service "":This operation returned because the timeout period expired.
try 'C:\Program Files\MongoDB\Server\4.4\bin\mongo.exe --help' for more information

表明我的 ISP 已为我阻止了此操作。 当我连接 vpn 时,系统要求我输入用户名的密码,然后出现错误:

connecting to: mongodb://cluster0-shard-00-00.6ss5b.mongodb.net:27017,cluster0-shard-00-01.6ss5b.mongodb.net:27017,cluster0-shard-00-02.6ss5b.mongodb.net:27017/myFirstDatabase?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=atlas-kcfk5f-shard-0&ssl=true
{"t":{"$date":"2021-06-17T04:19:26.714Z"},"s":"I",  "c":"NETWORK",  "id":4333208, "ctx":"ReplicaSetMonitor-TaskExecutor","msg":"RSM host selection timeout","attr":{"replicaSet":"atlas-kcfk5f-shard-0","error":"FailedToSatisfyReadPreference: Could not find host matching read preference { mode: \"nearest\" } for set atlas-kcfk5f-shard-0"}}


*** You have failed to connect to a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.

Error: connect failed to replica set atlas-kcfk5f-shard-0/cluster0-shard-00-00.6ss5b.mongodb.net:27017,cluster0-shard-00-01.6ss5b.mongodb.net:27017,cluster0-shard-00-02.6ss5b.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

我已经将集群的所有 IP 列入白名单,将 ip 设置为 0.0.0.0/0 我的用户具有管理员权限。 在 vpn 上,我无法打开我在某处读到的 url http://portquiz.net:27017/,这意味着端口 27017 被我阻止了。如何将 atlas 服务器连接到 mongo shell?

1 个答案:

答案 0 :(得分:0)

解决了!我的路由器有问题,当我使用移动热点运行命令时一切正常