繁体   English   中英

VSCode 停止连接到 MongoDB 服务器 - NodeJS

[英]VSCode Stops Connecting to MongoDB Server - NodeJS

我有一个 NodeJS 应用程序,它使用Mongoose在我的MongoDB数据库中存储(少量)数据。 当我的项目中的任何文件被保存时,我使用Nodemon自动重启服务器。 当我第一次打开 VSCode 终端时,我输入npm start ,通常在我退出 VSCode 之前一直保留它。 在我让服务器自动重启一段时间后,我的应用程序停止连接到 MongoDB。自从我开始使用 Mongo 以来,这种情况一直在发生,但我仍然没有找到解决方案。 这是我得到的错误,一段时间后应用程序尝试连接到 Mongo 数据库:

C:\Users\enric\Desktop\NodeJS Course\Section 14 - Sessions and Cookies\Online Shop Website\node_modules\mongodb\lib\utils.js:671
          throw error;
          ^

Error: Error connecting to db: queryTxt ETIMEOUT nodecoursecluster.lmj6z.mongodb.net
    at C:\Users\enric\Desktop\NodeJS Course\Section 14 - Sessions and Cookies\Online Shop Website\node_modules\connect-mongodb-session\index.js:78:17
    at C:\Users\enric\Desktop\NodeJS Course\Section 14 - Sessions and Cookies\Online Shop Website\node_modules\mongodb\lib\utils.js:668:9       
    at C:\Users\enric\Desktop\NodeJS Course\Section 14 - Sessions and Cookies\Online Shop Website\node_modules\mongodb\lib\mongo_client.js:225:23
    at C:\Users\enric\Desktop\NodeJS Course\Section 14 - Sessions and Cookies\Online Shop Website\node_modules\mongodb\lib\operations\connect.js:284:21
    at QueryReqWrap.callback (C:\Users\enric\Desktop\NodeJS Course\Section 14 - Sessions and Cookies\Online Shop Website\node_modules\mongodb\lib\core\uri_parser.js:90:18)
    at QueryReqWrap.onresolve [as oncomplete] (node:dns:203:10)
[nodemon] app crashed - waiting for file changes before starting...

有什么办法可以解决这个问题吗?

(如果有人提出要求,我肯定会提供任何其他需要的信息。)

我可以通过将 DNS 更改为 Google 的 8888 8844 来解决此问题。我观看了这个视频。

暂无
暂无

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

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