1

I've installed mongodb-community version 5.0 using brew, following this post's answer for M1 Apple Silicon Macs: How to install Mongodb on Apple M1 chip

Everything works fine, until the 6th step.

  1. After running "mongo" in my terminal, I get the following errors.

  2. I searched over stackoverflow and suspected that perhaps the mongodb service is not running, but the command "brew services list" gives the following output.

  3. Running "mongod" gives the following error.

  4. Yet, checking "mongo --version" gives a clear indication of installation.

I have also uninstalled mongodb various times, started afresh with the whole procedure.


I'm so frustrated at this point. It would be really helpful if someone could let me know what's wrong in this process/how I could fix it.

PS: This is one of my first posts and I'm sorry if it is not structured well or does not follow a community guideline. I can try to edit the post if any rule is violated.

Thank you.

Rahul Rana
  • 13
  • 3
  • Getting "connection refused" means nothing is listening on that port, which would imply that step #5 didn't work properly. – Joe Nov 12 '21 at 23:31

2 Answers2

2

This solution worked for me Read-only file system when attempting mkdir /data/db on Mac rom the official docs https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

Install homebrew and run the following commands

sudo chown -R $(whoami) $(brew --prefix)/*

then

brew tap mongodb/brew

then

brew install mongodb-community@4.2

and

brew services start mongodb-community

or

mongod --config /usr/local/etc/mongod.conf

then

ps aux | grep -v grep | grep mongod

and

mongo

to verify you can run show dbs in the mongo shell

Faisal Nazik
  • 2,367
  • 4
  • 17
  • 40
1

Please follow this step for reinstalling mongodb, it works for me:

  • 1st: run this command (Prerequisites)
xcode-select --install
\\note: Homebrew requires the Xcode commandline tools
  • 2nd: install Homebrew for M1 chip (Prerequisites)
  • 3rd: run this command to get Homebrew formula that work with mongodb
brew tap mongodb/brew
  • 4th: run this command to get mongodb version 5
brew install mongodb-community@5.0
  • 5th: run this command to run mongodb in the background
brew services start mongodb-community@5.0
// I notice that if I don't run this command I cannot connect to the server and receive the same error message like you
  • 6th: just run mongo and enjoy. I hope it works.
Heang Sok
  • 144
  • 5