如何将MongoClient连接到从副本集



我试图使用MongoClient GUI应用程序连接到MongoDB副本集。这是我的URL的结构,但它不工作:

mongodb://username:password@host-01:27017,host-02:27017,host-03:27017/mydb?authSource=mydb&replicaSet=rs0&ssl=true&sslValidate=false

我得到类似这样的错误:

Couldn't connect: server host-03:27017 received an error {"name":"MongoError","message":"read ECONNRESET"}

这是在mac上,host-01, host-02和host-03指向错误的/etc/hosts

ip地址

服务器正在响应ping请求,但是响应的服务器是错误的。因此,确保您的服务器指向实际的MongoDB节点。

最新更新