I check the MongoDB service is in running and I can connect MongoDB unsing /bin/mongo.exe BUT I cannot connect to MongoDB server using nodejs driver.
My codes are working on Windows 10. The error messages are below.
C:\Documents and Settings\Administrator\Desktop\src\server>node server.js
Listening on port 80
C:\Documents and Settings\Administrator\Desktop\src\server\node_modules\mongodb\
lib\mongo_client.js:225
throw err
^
MongoError: failed to connect to server [127.0.0.1:27017] on first connect
at null.<anonymous> (C:\Documents and Settings\Administrator\Desktop\src\ser
ver\node_modules\mongodb\node_modules\mongodb-core\lib\topologies\server.js:313:
35)
at emitOne (events.js:77:13)
at emit (events.js:169:7)
at null.<anonymous> (C:\Documents and Settings\Administrator\Desktop\src\ser
ver\node_modules\mongodb\node_modules\mongodb-core\lib\connection\pool.js:260:12
)
at g (events.js:260:16)
at emitTwo (events.js:87:13)
at emit (events.js:172:7)
at Socket.<anonymous> (C:\Documents and Settings\Administrator\Desktop\src\s
erver\node_modules\mongodb\node_modules\mongodb-core\lib\connection\connection.j
s:162:49)
at Socket.g (events.js:260:16)
at emitOne (events.js:77:13)
Use lower version of mongodb driver. In this case, I use 1.4.