服务器重启后mongodb报错
/home/wwwroot/alexhzh.com/node/blog/node_modules/connect-mongo/lib/connect-mongo.js:153
throw new Error('Error connecting to database');
^
Error: Error connecting to database
at /home/wwwroot/alexhzh.com/node/blog/node_modules/connect-mongo/lib/connect-mongo.js:153:17
at /home/wwwroot/alexhzh.com/node/blog/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js:229:16
at null.<anonymous> (/home/wwwroot/alexhzh.com/node/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> (/home/wwwroot/alexhzh.com/node/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> (/home/wwwroot/alexhzh.com/node/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:426:14
at process._tickCallback (node.js:415:13)
查询mongodb后
MongoDB shell version: 2.4.4 connecting to: test Tue Jun 11 22:46:04.598 JavaScript execution failed: Error: couldn’t connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112 exception: connect failed
6 回复
mongod 没有运行。看看是不是mongod 的 lock 文件还在。上次没有正常关机?
是的服务器关机stuck了 重装一遍mongo有用么
@741144175 不需要重装。
Ubuntu 下,看这个 lock 文件在不在,并删除。
/var/lib/mongodb$ sudo rm mongod.lock
不是 Ubuntu 的话,找找 MongoDB 的 log 和 lock 文件。
谢谢~ 解决了