简体   繁体   English

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

[英]Cant connect atlas server to mongo shell

I am very new to mongodb and atlas.我对 mongodb 和 atlas 很陌生。 I am trying to connect my atlas server to mongo shell while learning web development.我正在尝试在学习 Web 开发时将我的 atlas 服务器连接到 mongo shell。 I am trying to run the command:我正在尝试运行命令:

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

If i run on my internet without vpn, I get the error:如果我在没有 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

Indicating that my ISP has blocked this for me.表明我的 ISP 已为我阻止了此操作。 When I do connect a vpn, I am asked for the password to my username, and then get the error:当我连接 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

I have already whitelisted all IPs for my cluster, set ip to 0.0.0.0/0 My user has admin privileges.我已经将集群的所有 IP 列入白名单,将 ip 设置为 0.0.0.0/0 我的用户具有管理员权限。 While on vpn, i cannot open the url http://portquiz.net:27017/ which I read somewhere means that port 27017 is blocked for me.在 vpn 上,我无法打开我在某处读到的 url http://portquiz.net:27017/意味着端口 27017 被我阻止了。 What do I do to connect atlas server to mongo shell?我该怎么做才能将 atlas 服务器连接到 mongo shell?

Solved!解决了! was some problem with my router, everything worked fine when i used mobile hotspot to run the command我的路由器有问题,当我使用移动热点运行命令时一切正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM