已经解决了,目录权限的问题,没有启动成功。
在看nswbmw 的教程 https://github.com/nswbmw/N-blog/wiki/_pages 然后一步步来,才到mongodb配置的时候就出问题,伤心。 刚到这里:https://github.com/nswbmw/N-blog/wiki/第一章–Express-MongoDB搭建多人博客#会话支持 然后报错如下: MANIHOME:blog manihome$ node app Express server listening on port 3000
/Users/manihome/blog/node_modules/connect-mongo/lib/connect-mongo.js:155 throw Error(‘Error connecting to database <’ + err + ‘>’); ^ Error: Error connecting to database <Error: failed to connect to [127.0.0.1:27017]> at Error (<anonymous>) at /Users/manihome/blog/node_modules/connect-mongo/lib/connect-mongo.js:155:17 at /Users/manihome/blog/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js:229:16 at null.<anonymous> (/Users/manihome/blog/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/server.js:578:7) at EventEmitter.emit (events.js:106:17) at null.<anonymous> (/Users/manihome/blog/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:139:15) at EventEmitter.emit (events.js:98:17) at Socket.<anonymous> (/Users/manihome/blog/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/connection.js:475:10) at Socket.EventEmitter.emit (events.js:95:17) at net.js:441:14
怎么解决这个问题?
failed to connect to [127.0.0.1:27017]
你能不能用 mongo 命令连接到 mongodb 数据库?
就像这样:
‘’’ $ mongo MongoDB shell version: 2.4.3 connecting to: test
‘’’
‘’’ 不好使了?
mongo 连不上。
目测你没开mongodb。