昨天它运行良好,现在它给了我这个错误。我创建的 API 工作正常,所有请求都工作正常,现在我不知道出了什么问题。
我将 ng serve 用于我的 Angular 应用程序,将 node app.js 用于我的 API 服务器,一切正常,为什么现在不能连接?
Running on port 4000...
(node:13096) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:13096) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connection 0 to localhost:27017 timed out]
at Pool.<anonymous> (C:\Users\Heiko\Documents\parkingApi\node_modules\mongodb-core\lib\topologies\server.js:564:11)
at Pool.emit (events.js:182:13)
at Connection.<anonymous> (C:\Users\Heiko\Documents\parkingApi\node_modules\mongodb-core\lib\connection\pool.js:317:12)
at Object.onceWrapper (events.js:273:13)
at Connection.emit (events.js:182:13)
at Socket.<anonymous> (C:\Users\Heiko\Documents\parkingApi\node_modules\mongodb-core\lib\connection\connection.js:257:10)
at Object.onceWrapper (events.js:273:13)
at Socket.emit (events.js:182:13)
at Socket._onTimeout (net.js:448:8)
at ontimeout (timers.js:424:11)
at tryOnTimeout (timers.js:288:5)
at listOnTimeout (timers.js:251:5)
at Timer.processTimers (timers.js:211:10)
(node:13096) 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:13096) [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.
日志清楚地显示您的节点服务器无法连接到 MongoDB。原因可能是任何。让我列出几种可能性。
您可以使用以下命令检查来自 shell 的连接:
mongod "mongodb_host_url"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句