0

Running on MacOS Monterey

I am receiving this message after trying to run the mongoshell mongosh

Connecting to:      mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.10.1
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017

I made sure to stop and start backup the mongoDb Community using

brew services start mongodb/brew/mongodb-community

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

I have also tried completely reinstalling Homebrew and MongoDb with no luck.

Here is my Mongod file now and I believe this is where the problem currently is

Asio socket.set_option failed with std::system_error","attr":{"note":"acceptor TCP fast open","option":{"level":6,"name":261,"data":"00 04 00 00"},"error":{"what":"set_option: Invalid argument","message":"Invalid argument","category":"asio.system","value":22}}}
{"t":{"$date":"2023-07-29T19:02:29.473-07:00"},"s":"I",  "c":"STORAGE",  "id":22270,   "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"/usr/local/var/mongodb","storageEngine":"wiredTiger"}}
{"t":{"$date":"2023-07-29T19:02:29.474-07:00"},"s":"I",  "c":"STORAGE",  "id":22315,   "ctx":"initandlisten","msg":"Opening WiredTiger","attr":{"config":"create,cache_size=3584M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false

Here is /usr/local/etc

systemLog:
  destination: file
  path: /usr/local/var/log/mongodb/mongo.log
  logAppend: true
storage:
  dbPath: /usr/local/var/mongodb
net:
  bindIp: 127.0.0.1
Jcurrr0
  • 1
  • 1
  • Check the mongod logfile, typically `/var/log/mongodb/mongod.log`. Is it really running? – Wernfried Domscheit Jul 28 '23 at 07:36
  • -bash: /var/log/mongodb/mongod.log: No such file or directory is what i get when i run that command. Which is kind of confusing given the successful message when running brew services start. – Jcurrr0 Jul 28 '23 at 14:54
  • Have a look at config file, usually `/etc/mongod.conf` at `systemLog.path`. Indeed, it looks strange when it says "Successfully started" – Wernfried Domscheit Jul 28 '23 at 15:04
  • /usr/local/etc/mongod.conf `-bash: /usr/local/etc/mongod.conf: Permission denied` How would I go about fixing this? – Jcurrr0 Jul 28 '23 at 15:32
  • Remove file `/tmp/mongodb-27017.sock` manually. Most likely there was an unclean shutdown earlier. Or you try to start `mongod` multiple times, that's not possible. – Wernfried Domscheit Jul 28 '23 at 16:18
  • Change permission of `/usr/local/etc/mongod.conf`. Usually they are readable for every user. – Wernfried Domscheit Jul 28 '23 at 16:19
  • You must read or edit these file, not try to execute them. – Wernfried Domscheit Jul 28 '23 at 19:11
  • Please edit your question and add such information there instead of a comment. As shown, the logfile is `/usr/local/var/log/mongodb/mongo.log` – Wernfried Domscheit Jul 28 '23 at 19:50
  • Apologies and thank you for helping. – Jcurrr0 Jul 28 '23 at 20:31
  • I solved it! The problem was I needed to change the dbpath file from dbPath: /usr/local/var/mongodb to /System/Volumes/Data/data/db. I'm not sure the exact reasonings behind this. However I did read that Catalina and onwards added a new volume to the hard drive and creates a special folder where the MongoDB files have to go. If anyone has this problem in the future here is the link I found that helped out! https://blog.codewithdan.com/installing-mongodb-on-mac-catalina-using-homebrew/ – Jcurrr0 Jul 31 '23 at 21:15
  • The blog is not very precise. When you just start `mongod` then no config file is read and the default `dbPath` is used. You need to specify the config file - which is typically the case when you install and run MongoDB as a service. See also https://stackoverflow.com/questions/12738322/what-is-the-default-database-path-for-mongodb/67043090#67043090 – Wernfried Domscheit Aug 01 '23 at 05:50

0 Answers0