Cannot connect to mongodb atlas through mongo shell

两盒软妹~` 提交于 2020-08-22 09:42:07

问题


I've checked other similar posts but none worked for my case.

I upgraded my mongo shell right before connecting to MongoDB Atlas, from which I created a free sandbox database. I used this following for my connection, which was given by atlas.

mongo "mongodb+srv://cluster0-z2lf6.mongodb.net/test" --authenticationDatabase admin --username <user> --password <password>

image of the user of database: image of the user of database

screenshot of the overview of the database: screenshot of the overview of the database

These are the detail of database: These are the detail of database

However, the terminal displays this (I only included about 15 lines, the rest are repetitions.):

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.

What could be the reason for this connection error?


回答1:


In my case reason was that provider changed my ip address (I have dynamic ip, behind NAT)

after I've updated ip whitelist, connection was restored




回答2:


Actually the reason why I couldn't connect is because I had a network restriction from my university's wifi. I was given a test url http://portquiz.net:27017 from MongoDB's support team, I opened it in a browser and I couldn't access it. I changed to another place with wifi and it worked.




回答3:


The new atlas ui - please note that for better security you should not use 0.0.0.0/0 nut your own ip address or use available timer to terminate the rule




回答4:


I think I was in the same certificate class with you. I just finished with the ending certificate date being Dec 12.

I saw your other post that people downgraded but tried to contact you.

I am not near my computer but I can send you my credentials (as a student) and see if you can log in. In your other post you asked a question regarding the data model and where to get something similar.

On YouTube there is an excellent mongodb tutorial by a gentleman from Europe. I did it before University. Are you interested? I can get the link for you? It is the same information but even better explained.

It will have to be tomorrow (for me) though. I am in Taiwan.



来源:https://stackoverflow.com/questions/47958683/cannot-connect-to-mongodb-atlas-through-mongo-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!