我检查了其他类似的帖子,但没有一个适合我的情况.
我在连接到MongoDB Atlas之前就升级了我的mongo shell,我从中创建了一个免费的沙箱数据库.我使用以下内容进行连接,由atlas提供.
mongo "mongodb+srv://cluster0-z2lf6.mongodb.net/test" --authenticationDatabase admin --username <user> --password <password>
数据库用户的图像:
数据库概述的屏幕截图:
这些是数据库的细节:
但是,终端显示这个(我只包括大约15行,其余的是重复.):
MongoDB shell version v3.6.0
connecting to: mongodb+srv://cluster0-z2lf6.mongodb.net/test
2017-12-24T14:39:42.806+0800 I NETWORK [thread1] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-z2lf6.mongodb.net.:27017,cluster0-shard-00-01-z2lf6.mongodb.net.:27017,cluster0-shard-00-02-z2lf6.mongodb.net.:27017
2017-12-24T14:39:42.990+0800 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Failed to connect to 34.232.245.97:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:42.991+0800 W NETWORK [thread1] Failed to connect to 35.168.27.238:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:43.492+0800 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Failed to connect to 52.20.90.64:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:43.492+0800 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Unable to reach primary for set Cluster0-shard-0
2017-12-24T14:39:43.492+0800 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2017-12-24T14:39:43.997+0800 W NETWORK [thread1] Failed to connect to 35.168.27.238:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:44.000+0800 W NETWORK [thread1] Failed to connect to 34.232.245.97:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:44.003+0800 W NETWORK [thread1] Failed to connect to 52.20.90.64:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:44.004+0800 W NETWORK [thread1] Unable to reach primary for set Cluster0-shard-0
2017-12-24T14:39:44.004+0800 I NETWORK [thread1] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
这种连接错误的原因是什么?
最佳答案 实际上我无法连接的原因是因为我的大学无线网络有网络限制.我从MongoDB的支持团队那里得到了一个测试网址http://portquiz.net:27017,我在浏览器中打开它,我无法访问它.
我改变到另一个有wifi的地方,它工作.