Connection refuse for mongo macos

Viewed 1760

Whenever I try to execute the command mongo from my terminal, this errors pops up:

MongoDB shell version v4.4.0
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:362:17
@(connect):2:6
exception: connect failed
exiting with code 1

I've been following this tutorial in order to install mongo on my MacBook Pro and failed by creating the /data/db. Later, this other article appeared upon me. The second one orders me to run the next piece of code from my terminal:

mongo — dbpath /System/Volumes/Data/data/db

But the same error that I pasted at the begining appears.

Is there anything I can do to install and keep mongo running?

OS: macOS Catalina - 10.15.16

Thanks in advance!

2 Answers

Try to:

brew services start mongodb/brew/mongodb-community

For macOS user:

1、reinstall mongodb-community

brew uninstall mongodb-community
brew cleanup
brew install mongodb/brew/mongodb-community

2、config and start

sudo mongod --config /usr/local/etc/mongod.conf
brew services start mongodb-community
Related