Brew mongodb-community server error

I am using macOS Big Sur. I have installed mongodb-community@4.4 server on mac recently with help of MongoDB Homebrew Tap. After successful installation, I run “brew services start mongodb/brew/mongodb-community” on terminal. I receive below result :

Successfully started mongodb-community (label: homebrew.mxcl.mongodb-community)

But, when I check for running server with “brew services list”, I get below status :
mongodb-community error nileshpanhale /Users/nileshpanhale/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

And if I try to connect server with “mongo” shell the I get below error :

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

As I am new to macOS and MongoDB. Request you to please help me on an urgent basis with the stepwise solution. Due to this error, my development is completely stopped.

Thanks in advance.

1 Like

Is the command to start services correct
It should be something like
brew services start mongodb/brew/mongodb-community@4.4
Please check documentation

Unless your mongod is up you cannot connect to mongodbCan you check mongod.log.It will give more details on why it failed to start
Could be permissions issue or misssing dbpath dir etc

if we do not mention the community version then the command will take default stable version of MongoDB, mostly latest one.
To check logs, I can not run mongod.log command, as mongod is not working with macOS.
If there is permissions issue then how can I know that?
I tried to set/create dbpath but macOS Big Sur won’t allow to modify root directory.

Yes this is a known issue.They removed access to root dir

First identify your mongod.conf.It should be under /usr/local
If you see the contents of config file it will show your mongo.log path
If it is failing due to dbpath issue simply create a directory under your home directory and update your config file
Restart the service.It should start mongod on default port 27017

You can start your own mongod on another port say 28000 by below command
mongod --port 28000 --dbpath your_dbpath --logpath your_logpath --fork
Give valid full path for dbpath and logpath where the owner of mongod can write

Check mongodb documentation and this link

https://saiankit30.medium.com/setting-up-mongodb-on-macos-catalina-common-errors-and-their-solutions-72fd66fb8a86

A post was split to a new topic: Facing error from MongoDB database side when i use celery with MongoDB