Heim > Fragen und Antworten > Hauptteil
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:\projects\myblog\node_modules\mongodb-core\lib\topologies\server.js:328:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:191:7)
at Connection.<anonymous> (D:\projects\myblog\node_modules\mongodb-core\lib\connection\pool.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:\projects\myblog\node_modules\mongodb-core\lib\connection\connection.js:177:49)
过去多啦不再A梦2017-05-17 10:04:10
估计您已经找到原因了。
因为MongoDB没有启动。在Windows操作系统启动MongoDB吧!
供参考。
Love MongoDB! Have fun!
PHPz2017-05-17 10:04:10
D:\projects\myblog>mongo
MongoDB shell version v3.4.4
connecting to: mongodb://127.0.0.1:27017
2017-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:6
exception: connect failed