这是什么错误{MongoNetworkError:连接0到127.0.0.1:8080已关闭}?

时间:2019-01-02 19:44:33

标签: javascript node.js mongodb

这是我的代码。我想连接到Mongodb,但发出{MongoNetworkError: connection 0 to 127.0.0.1:27017 closed}错误。

 MongoClinet.connect("mongodb://127.0.0.1:27017/demo",{ useNewUrlParser: true},(err,db)=>{
        if(err)
            console.log(err.toString());
        else{
            console.log("Connected");
        }
    });


MongoNetworkError: connection 0 to localhost:27017 closed
MongoNetworkError: connection 1 to localhost:27017closed
MongoNetworkError: connection 2 to localhost:27017 closed

1 个答案:

答案 0 :(得分:0)

删除mongod.lock并(重新)启动mongod服务器。