「求助」初学,在搭mongodb的时候报错。
发布于 1年前 作者 manihome 849 次浏览

已经解决了,目录权限的问题,没有启动成功。

在看nswbmw 的教程 https://github.com/nswbmw/N-blog/wiki/_pages 然后一步步来,才到mongodb配置的时候就出问题,伤心。 刚到这里:https://github.com/nswbmw/N-blog/wiki/%E7%AC%AC%E4%B8%80%E7%AB%A0–Express-MongoDB%E6%90%AD%E5%BB%BA%E5%A4%9A%E4%BA%BA%E5%8D%9A%E5%AE%A2#%E4%BC%9A%E8%AF%9D%E6%94%AF%E6%8C%81 然后报错如下: 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

怎么解决这个问题?

5 回复

failed to connect to [127.0.0.1:27017]

你能不能用 mongo 命令连接到 mongodb 数据库?

就像这样:

‘’’ $ mongo MongoDB shell version: 2.4.3 connecting to: test

‘’’

‘’’ 不好使了?

mongo 连不上。

目测你没开mongodb。

回到顶部