无法连接到服务器127.0.0.1:27017连接尝试失败MongoDB
问题描述:
我正在使用Ubuntu OS 16.04.我正在使用以下命令启动mongodb ::
sudo service mongod start
然后
mongo
I am working on Ubuntu OS 16.04. I am starting mongodb using commands::
sudo service mongod start
and then
mongo
它为我生成了此错误::
It generated this error for me::
MongoDB shell version v4.0.1
connecting to: mongodb://127.0.0.1:27017
2018-09-27T16:50:41.345+0530 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed
现在我无法启动mongodb.如何解决此错误以及这些错误的原因是什么. 我针对此问题尝试了所有解决方案,但没有找到任何解决方案.
Now I am not able to start mongodb. How to resolve this error and what are the causes of these error. I tried all of solution for this problem but didn't find any solution.
答
mongod --repair对我有用,
mongod --repair worked for me ,
sudo mongod --repair
sudo mongod
然后打开其他选项卡/终端:
Then open a different tab/terminal:
mongo
此后,您的本地设置将正常运行
After this your local setup will work properly