我有一个NodeJS应用程序,它使用Mongoose在我的MongoDB数据库中存储(少量)数据。在保存项目中的任何文件时,我使用Nodemon自动重新启动服务器。当我第一次打开VSCode终端时,我会在它中输入VSCode,通常直到退出VSCode为止。在我使服务器自动重新启动几次之后,我的应用程序停止连接到MongoDB。这已经发生了,因为我已经开始使用蒙戈,但我仍然没有找到解决办法。这是我遇到的错误,经过一段时间,应用程序试图连接到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...有什么办法能解决这个问题吗?
(如果有人问起,我一定会提供任何额外的所需信息。)
发布于 2020-12-04 06:30:08
我能够通过将DNS更改为谷歌的88888844来解决这个问题。我跟踪了这的视频。
https://stackoverflow.com/questions/65113457
复制相似问题