繁体   English   中英

mongoDB 错误:无法连接到 MongoDB Atlas 集群中的任何服务器

[英]mongoDB error : Could not connect to any servers in your MongoDB Atlas Cluster

const mongoose = require('mongoose');

mongoose.connect('mongodb://DATABASE_LOGIN1:[MyPass]@mee6copycluster-shard-00-00.r86qy.mongodb.net:27017/djsdashboard/?authSource=admin', {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

错误: UnhandledPromiseRejectionWarning: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist UnhandledPromiseRejectionWarning: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist

我不知道如何解决请帮忙

如果您需要更多信息,请专门询问!

mongodb+srv://DATABASE_LOGIN1:[MyPass]@mee6copycluster-shard-00-00.r86qy.mongodb.net/admin?retryWrites=true&w=majority 给出错误:

(node:7288) UnhandledPromiseRejectionWarning: Error: querySrv ENOTFOUND _mongodb._tcp.mee6copycluster-shard-00-00.r86qy.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19)
(node:7288) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7288) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

我遇到了同样的问题,我通过简单地在我的 MongoDB 仪表板的“网络访问”部分中选择“允许从任何地方访问”按钮来解决它。

这可能是由于通过 VPN 或代理的连接。

现在您可以连接到相应的服务器和您指定的端口。

解决它:

mongoose.connect('mongodb://DATABASE_LOGIN1:[MyPass]@mee6copycluster-shard-00-00.r86qy.mongodb.net:27017,mee6copycluster-shard-00-01.r86qy.mongodb.net:27017,mee6copycluster-shard-00-02.r86qy.mongodb.net:27017/djsdashboard?ssl=true&replicaSet=atlas-5r6qbu-shard-0&authSource=admin&retryWrites=true&w=majority', {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

那为我修好了

暂无
暂无

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

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