问题描述
events.js:163 throw er; // Unhandled ’error’ event ^MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017] at Pool.<anonymous> (D:projectsmyblognode_modulesmongodb-corelibtopologiesserver.js:328:35) at emitOne (events.js:96:13) at Pool.emit (events.js:191:7) at Connection.<anonymous> (D:projectsmyblognode_modulesmongodb-corelibconnectionpool.js:274:12) at Object.onceWrapper (events.js:293:19) at emitTwo (events.js:106:13) at Connection.emit (events.js:194:7) at Socket.<anonymous> (D:projectsmyblognode_modulesmongodb-corelibconnectionconnection.js:177:49)
问题解答
回答1:估计您已经找到原因了。
因为MongoDB没有启动。在Windows操作系统启动MongoDB吧!
供参考。
Love MongoDB! Have fun!
回答2:D:projectsmyblog>mongoMongoDB shell version v3.4.4connecting to: mongodb://127.0.0.1:270172017-05-14T23:17:25.098+0800 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017 after 5000ms milliseconds, giving up.2017-05-14T23:17:25.099+0800 E QUERY [thread1] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed :connect@src/mongo/shell/mongo.js:237:13@(connect):1:6exception: connect failed