为什么nodejs不连接猫鼬,但可以连接本地主机?

时间:2020-02-15 23:54:53

标签: node.js database mongodb mongoose server

connection error: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16) {
  name: 'MongoNetworkError',
  [Symbol(mongoErrorContextSymbol)]: {}
}]
    at Pool.<anonymous> (C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\topologies\server.js:433:11)
    at Pool.emit (events.js:223:5)
    at C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\connection\pool.js:577:14
    at C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\connection\pool.js:1007:11
    at C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\connection\connect.js:31:7
    at callback (C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\connection\connect.js:247:5)
    at Socket.<anonymous> (C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\connection\connect.js:276:7)
    at Object.onceWrapper (events.js:313:26)
    at Socket.emit (events.js:223:5)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  name: 'MongoNetworkError',
  [Symbol(mongoErrorContextSymbol)]: {}
}
(node:7456) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16) {
  name: 'MongoNetworkError',
  [Symbol(mongoErrorContextSymbol)]: {}
}]
    at Pool.<anonymous> (C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\topologies\server.js:433:11)
    at Pool.emit (events.js:223:5)
    at C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\connection\pool.js:577:14
    at C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\connection\pool.js:1007:11
    at C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\connection\connect.js:31:7
    at callback (C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\connection\connect.js:247:5)
    at Socket.<anonymous> (C:\Users\carlo\Desktop\node-app\node_modules\mongodb\lib\core\connection\connect.js:276:7)
    at Object.onceWrapper (events.js:313:26)
    at Socket.emit (events.js:223:5)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:7456) 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:7456) [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.

0 个答案:

没有答案