简体   繁体   English

使用 Node.js 驱动程序连接到 MongoDB 地图集失败

[英]Connection to MongoDB atlas using Node.js driver fails

  at QueryReqWrap.onresolve [as oncomplete] (dns.js:203:19) {
  errno: 'ETIMEOUT',
  code: 'ETIMEOUT',
  syscall: 'queryTxt',
  hostname: 'scheduly.1eln0.mongodb.net'
}

I'm facing the above connection Error while connecting with MongoDB Atlas.我在连接 MongoDB Atlas 时遇到上述连接错误。 I've double-checked my username and password.我已经仔细检查了我的用户名和密码。 I've whitelisted all the IP's.我已将所有 IP 列入白名单。 I'm stuck in the middle of a project and cannot connect to the DB itself.我被困在一个项目的中间,无法连接到数据库本身。 my connection strings are:我的连接字符串是:

const mongoose = require("mongoose");
const mongodb = require("mongodb");
const uri = "mongodb+srv://ghulamghousdev:***********@scheduly.1eln0.mongodb.net/scheduly?retryWrites=true&w=majority

mongoose
  .connect(uri, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
  })
  .then(() => {
    console.log("Connected");
  })
  .catch((err) => console.log(err));

The name of the Database on MongoDB atlas is scheduly. MongoDB图集上的数据库名称是schedule。

Have you tried to add the ip of your VPS, host to the IP Whitelist of Network access?您是否尝试将您的 VPS 的 ip、主机添加到网络访问的 IP 白名单? You can see more details for that setting from here https://docs.atlas.mongodb.com/security-whitelist/您可以从此处查看该设置的更多详细信息https://docs.atlas.mongodb.com/security-whitelist/

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

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