无法使用带有连接字符串的 Mongoose 连接到 MongoDB Atlas [英] Unable to connect to MongoDB Atlas using Mongoose with connection string

查看:34
本文介绍了无法使用带有连接字符串的 Mongoose 连接到 MongoDB Atlas的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些是我收到的错误:

<前>(node:11692) UnhandledPromiseRejectionWarning: MongoNetworkError: connection 5 to cluster0-shard-00-01-wwvto.mongodb.net:27017 closed在 TLSSocket.(C:\Node Example\node-rest-shop\node_modules\mongodb-core\lib\connection\connection.js:276:9)在 Object.onceWrapper (events.js:273:13)在 TLSSocket.emit (events.js:187:15)在 _handle.close (net.js:606:12)在 TCP.done (_tls_wrap.js:386:7)

<前>(node:11692) UnhandledPromiseRejectionWarning:未处理的承诺拒绝.这个错误通过抛出没有 catch 块的异步函数内部,或者通过拒绝未使用 .catch() 处理的承诺.(拒绝编号:1)

<前>(节点:11692)[DEP0018] 弃用警告:不推荐使用未处理的承诺拒绝.在未来,未处理的承诺拒绝将终止 Node.js 进程带有非零退出代码.

解决方案

是的,您可以随时通过以下方式添加本地 IP 地址:

Security -> IP Whitelist 然后添加一个新的 IP.在那里您可以点击添加当前 IP 地址"以及任何评论:

These are the errors I received:

(node:11692) UnhandledPromiseRejectionWarning: MongoNetworkError: connection 5 to cluster0-shard-00-01-wwvto.mongodb.net:27017 closed
    at TLSSocket. (C:\Node Example\node-rest-shop\node_modules\mongodb-core\lib\connection\connection.js:276:9)
    at Object.onceWrapper (events.js:273:13)
    at TLSSocket.emit (events.js:187:15)
    at _handle.close (net.js:606:12)
    at TCP.done (_tls_wrap.js:386:7)

(node:11692) 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:11692) [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.

解决方案

Yes you can always add your local IP Address by going to:

Security - > IP Whitelist and then add a new IP. There you can click "ADD CURRENT IP ADDRESS" along with any comment:

这篇关于无法使用带有连接字符串的 Mongoose 连接到 MongoDB Atlas的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆