mongodb - 无法在 Mongodb Atlas 端口上连接

标签 mongodb mongodb-atlas

我正在使用 M0 GCP 实例。

我可以使用以下字符串连接到集群:

'mongodb+srv://my_user:my_pass@my_cluster-mbsnz.gcp.mongodb.net/db?retryWrites=true&w=majority'

我正在尝试使用另一个需要传递主机和端口的客户端,但无法连接。

我尝试 telnet 到端口 27017,但由于某种原因我无法直接连接到端口。
curl http://my_cluster-mbsnz.gcp.mongodb.net:27017
curl: (7) Failed to connect to my_cluster-mbsnz.gcp.mongodb.net port 27017: Connection timed out

或者
telnet my_cluster-mbsnz.gcp.mongodb.net 27017
Trying 185.82.212.199...
^C -> After a long time waiting

可能有什么问题?

最佳答案

+srv url 使用 DNS 种子。在 map 集上,您可以单击进入集群,您应该能够看到主服务器和辅助服务器的 url,并使用这些 url 进行连接。您还应该可以使用 nslookup使用该连接字符串的一部分来获取该信息,但通过 UI 查找 url 可能更简单。

https://docs.mongodb.com/manual/reference/connection-string/

In order to leverage the DNS seedlist, use a connection string prefix of mongodb+srv: rather than the standard mongodb:. The +srv indicates to the client that the hostname that follows corresponds to a DNS SRV record. The driver or mongo shell will then query the DNS for the record to determine which hosts are running the mongod instances.

关于mongodb - 无法在 Mongodb Atlas 端口上连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57240994/

相关文章:

mongodb - 将数组字段中的每个 ObjectId 解析为另一个集合中的对象

node.js - MongoDB:删除唯一约束

mongodb - 使用 MongoDB 检查 Golang 中对象数组中的重复项

javascript - javascript中的树遍历

MongoDB Atlas 未连接到我的 golang 应用程序

node.js - 由于 MongoDB,Heroku 中的应用程序错误?

java - 如何在java中从MongoDB Atlas获取特定字段?

node.js - MongoDB 查询返回 null,即使它在从 mlab 迁移到 mongoDB atlas 后在集合中可用

MongoDB Atlas 搜索 - 搜索字符串中的多个术语具有 'and' 条件(不是 'or' )

mongodb - MongoDB 中单个父注释中的嵌套(子)注释