MongoDB - couldn't connect to server 127.0.0.1:27017, caused by :Connection refused : connect@src/mongo/shell/mongo.js:374:17

I installed mongodb with homebrew and I use Mac OS Big Sur when I start mongo db with

```
$ brew services start mongodb-community
```

It says that mongodb it successfully started but when i run

```
$ brew services list
```

The status of mongodb-community is “error” and if I try to type the command “mongo” in the cmd it gave me the problem explained in the title of this question:

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

Welcome to the community!

Error indicates your mongod is not up
You can verify by ps-ef|grep mongod

Issue could be dbpath directory
Does your mongod.log or system log show more details
Check your mongod.conf and see which path it is pointing to
On Macos there are known issues like /data/db is not accessible
You may have to modify your config file to point the dbpath to someother dir like your home dir