mongodb服务器连接错误

mongodb服务器连接错误
waseem@waseem-HP-Laptop-14q-cs0xxx:~$ mongo
MongoDB shell version v4.2.3
connecting to: mongodb://127.0.0.1:27017/? 
compressors=disabled&gssapiServiceName=mongodb
2020-03-03T16:17:52.233+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:341:17
@(connect):2:6
2020-03-03T16:17:52.271+0530 F  -        [main] exception: connect failed
2020-03-03T16:17:52.271+0530 E  -        [main] exiting with code 1

答案1

首先检查你的 mongo 服务是否正在运行。尝试使用以下命令启用 mongo sudo systemctl enable mongod

之后使用命令重新启动 mongo 服务。

sudo service mongod restart

相关内容