Connection refused: MongoDB 4.2 on Mac OS I am trying to set up a MongoDB 4.2.X Community instance on my local computer. 
However, I am getting the following error message:

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


I have followed all instructions on https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ and couldn't find any suitable help on the internet. 
Does anybody know how to fix this?

==&gt; Summary
  /usr/local/Cellar/mongodb-community/4.2.0: 21 files, 272.3MB, built in 5 seconds

Juliens-iMac:~ julien$ mongod --config /usr/local/etc/mongod.conf

Juliens-iMac:~ julien$ mongo
MongoDB shell version v4.2.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&amp;gssapiServiceName=mongodb
2019-10-19T11:47:04.088+0200 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
2019-10-19T11:47:04.090+0200 F  -        [main] exception: connect failed
2019-10-19T11:47:04.091+0200 E  -        [main] exiting with code 1

Juliens-iMac:~ julien$ brew services list
Name              Status  User   Plist
docker-machine    started julien /Users/julien/Library/LaunchAgents/homebrew.mxcl.docker-machine.plist
mongodb-community started julien /Users/julien/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
I faced same problem on my mac catalina.
So I followed instructions you mentioned, and then removed everything manually from /usr/local/var/mongodb

After restarting the mongodb-community service I could successfully connect to it.