【问题标题】:i am getting this error while connecting to database in mongoDB , what should i do我在连接到 mongoDB 中的数据库时出现此错误,我该怎么办
【发布时间】:2022-12-29 23:21:00
【问题描述】:

const serverSelectionError = new ServerSelectionError(); 连接到 MongoDB 中的数据库时出现此错误,我该怎么办

【问题讨论】:

  • 这里没有足够的信息供我们提供帮助。报告的完整错误/堆栈跟踪是什么?您使用的数据库拓扑结构是什么?这是否有效,或者这是最近出现的新错误?您使用的是什么版本的 MongoDB 和 Node 驱动程序? ETC

标签: mongodb mern


【解决方案1】:

如果您使用的节点版本大于 17,请尝试将 URL 中的 localhost 替换为 127.0.0.1。 您可以复制以下代码。

mongoose.connect('mongodb://127.0.0.1:27017/<your DB name>',{useNewUrlParser:true});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-20
    • 1970-01-01
    • 2021-04-27
    • 1970-01-01
    • 1970-01-01
    • 2022-11-13
    • 1970-01-01
    相关资源
    最近更新 更多