简体   繁体   中英

Running `mongo` in the command line is giving error

I am trying to start a MERN app, I have installed mongo and any relevant things. But when I run mongo in my terminal the following appears. I have looked across the board but the solutions do not help me. I am also running on Ubuntu 20.04.

MongoDB shell version v4.4.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
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:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

Fixed the issue by running

$ sudo rm -rf /tmp/mongodb-27017.sock

$ sudo service mongod start

Try to start the MongoDB server first running mongod command or from task manager>services> MongoDB server> right-click and start it

Read this Document for more

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM