코린이의 기록

[MongoDB]MongoNetworkError: failed to connect to server 본문

Database/mongoDB

[MongoDB]MongoNetworkError: failed to connect to server

코린이예요 2020. 2. 25. 14:43
반응형

 

$ node startup.js
[2020-02-25T05:39:08.785Z] ERROR  : {"name":"MongoNetworkError","errorLabels":["TransientTransactionError"]}
(node:14508) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [10.20.1.252:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 10.20.1.252:27017]
    at Pool.<anonymous> (/root/devel/monitoring/dashboard-backend/node_modules/mongodb/lib/core/topologies/server.js:433:11)
    at Pool.emit (events.js:198:13)
    at createConnection (/root/devel/monitoring/dashboard-backend/node_modules/mongodb/lib/core/connection/pool.js:562:14)
    at connect (/root/devel/monitoring/dashboard-backend/node_modules/mongodb/lib/core/connection/pool.js:985:11)
    at makeConnection (/root/devel/monitoring/dashboard-backend/node_modules/mongodb/lib/core/connection/connect.js:40:11)
    at callback (/root/devel/monitoring/dashboard-backend/node_modules/mongodb/lib/core/connection/connect.js:262:5)
    at Socket.err (/root/devel/monitoring/dashboard-backend/node_modules/mongodb/lib/core/connection/connect.js:287:7)
    at Object.onceWrapper (events.js:286:20)
    at Socket.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:14508) 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:14508) [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.
^HMongoNetworkError^H10.20.1.252:27017mo 

mongoDB 가 실행되지 않았음

$ sudo service mongod start
Redirecting to /bin/systemctl start mongod.service

정상 동작

node startup.js 
[2020-02-25T05:43:54.399Z] DEBUG  : DB Uri: mongodb://10.20.1.252:27017/monitoring
(node:15065) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
[2020-02-25T05:43:54.712Z] INFO   : API server listening on 0.0.0.0:8080, in development
[2020-02-25T05:43:54.741Z] INFO   : Database connected.
반응형
Comments