Mongodb-community error homebrew.mxcl.mongodb-community.plist
Asked Answered
M

11

12

I've been having this error while running brew services start mongodb-community

mongodb-community error   root /Library/LaunchDaemons/homebrew.mxcl.mongodb-community.plist

I have tried re installing home brew, mongodb and a slew of other solutions but nothing has worked. Any help would be appreciated, thanks!

Microdot answered 15/12, 2020 at 15:6 Comment(0)
M
15

Hello so running sudo brew services start mongodb-community fixed it after stopping mongodb.

Microdot answered 15/12, 2020 at 20:22 Comment(5)
Adding sudo worked for me as well. But it wasn't the case before. Without using the sudo and I started the service and checked for the brew services list, I get the following status. mongodb-community error root /Library/LaunchDaemons/homebrew.mxcl.mongodb-community.plist. I am wondering this has some permission to add in the pList. But not sure how. Looking for help. – Rossini
can anyone expain why is it worked? I tried to follow the doc but it was not working properly. But after doing this it worked!! – Ravenna
This worked for me as well. I'm also getting the same status as @fredrickcyril – Reduce
sudo brew services start mongodb-community πŸ’―. – Ontogeny
Caution: This really shouldn't be the accepted answer. brew should not need to run with sudo. Their documentation is pretty clear about that. – Flavoprotein
A
8

I had the same issue. Finally found the error in /usr/local/var/log/mongodb/mongo.log which indicated that my database files in /usr/local/var/mongodb were too old (version 4.2) for this version of mongodb (version 4.4). Since I didn't need those files, I deleted them, and mongodb started up fine. Read your logs, they will tell you what's wrong.

Anaya answered 17/12, 2020 at 16:43 Comment(3)
After 30 mins of trying, this worked for me so thanks. If you previously had the original mongod homebrew installation (like me) this is likely to be your issue. – Reuben
Error message for reference: "This version of MongoDB is too recent to start up on the existing data files. Try MongoDB 4.2 or earlier."}" – Cohby
This worked for me also. I deleted my old database files from 2017 (mongo ver3?), and allowed mongodb-community to startup with it's default files (maybe I uninstalled and reinstalled mongo to get the default db files in there). Note that for latest macos, the default db folder is no longer /data/db. – Trudy
P
4

try to delete folder "dbPath", to delete that, look at your config to get the path like this:

systemLog:
  destination: file
  path: /opt/homebrew/var/log/mongodb/mongo.log
  logAppend: true
storage:
  dbPath: /opt/homebrew/var/mongodb
net:
  bindIp: 127.0.0.1, ::1
  ipv6: true

in my Case is /opt/homebrew/var/mongodb

now you need to folow this commands:

$cd /opt/homebrew/var

$rm mongodb

$mkdir mongodb

then:

brew services restart mongodb-community
Photocurrent answered 25/9, 2023 at 13:41 Comment(1)
Deleting /opt/homebrew/var/mongodb worked for me – Nguyen
D
3

Hello just debugged a similiar problem. If you attempt to run mongodb with root it shows error and the problem is likely a file permission problem.

You can confirm where (directory may vary this is the default): show mongo log with cat /usr/local/var/log/mongodb/mongo.log

You are most likely seeing a "Permission denied" error on a file. (mine was for a bunch of files).

You will need to run chown on those files:

chown -R <login> /usr/local/var/mongodb

should solve it.

You can verify by running ls -la <directory> and verifying everything is now owned by your login user.

Dripdry answered 28/5, 2021 at 17:33 Comment(0)
E
1

Another reason for this error might be that you forgot to enable the backwards-incompatible features of your old version. This might happen if you updated several versions one after the other. For example, if you wanted to migrate from 3.2 to 3.6, you would have to install all intermediate versions (in this case, 3.4), and for each of them you would have to enable the "backwards-incompatible 3.4 features" before installing the next version (in this case, 3.6), using this command:

db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } ) 

(as per instructions in https://www.mongodb.com/docs/manual/release-notes/3.4-upgrade-standalone/, for example). If you forgot to do that Version 3.6 would not start, showing in the log file (/usr/local/var/log/mongodb/mongo.log) the notice "* IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details."

Eisegesis answered 14/6, 2022 at 14:10 Comment(0)
A
1

I did stop sudo brew services stop mongodb-community and then start sudo brew services start mongodb-community, it fixed the issue.

Alarum answered 8/8, 2023 at 22:2 Comment(0)
G
0

I tried for 2 hours solving this problem. The problem was with an unexpected token in mongod.conf file, that made the [email protected] to not to start .

To track the issue open the .plist file look at the output log file location, you can find it after StandardErrorPath key.

Gorlicki answered 28/1, 2022 at 13:2 Comment(0)
L
0

Please refer https://blog.codewithdan.com/installing-mongodb-on-mac-catalina-using-homebrew/ I followed this to create a data/db folder under /System/Volumes/Data and updated the path in /usr/local/etc/mongod.conf for the variable 'dbPath:'

Make sure the user and user permissions (The user who creates this file is the same user who runs the brew service for Mongo)

Still my services haven't started. I got the error when I run 'brew services list'

Same error mentioned above on this issue.

When I checked /usr/local/var/log/mongodb/mongo.log

It Failed to unlink /tmp/mongodb-27017.sock this file.

Please refer the following link to solve this.(Just delete that .sock file)

https://www.dev2qa.com/how-to-fix-failed-to-unlink-socket-file-error-when-start-mongo-db-on-macos/

Then, I made sure the permissions for data/db are good

d-wx--x--x 3 name wheel 96 Mar 22 11:20 data

Then stopped the brew services for mongo and started again. It worked.

Linkboy answered 22/3, 2022 at 20:0 Comment(0)
M
0

Similiar to Rob Lopez / Craig Eddy's answer, here's what worked for me on macOS ventura 13, using [email protected] with homebrew:

I was getting the similar error after running brew services start mongodb-community

Name              Status        File
mongodb-community error  25600 ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

It always helps to check the logs using cat /usr/local/var/log/mongodb/mongo.log

In my case, looks like the last line states the problem "error":"IllegalOperation: Attempted to create a lock file on a read-only directory: /usr/local/var/mongodb"

{"t":{"$date":"2023-06-03T14:30:42.768+08:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/usr/local/etc/mongod.conf","net":{"bindIp":"127.0.0.1, ::1","ipv6":true},"storage":{"dbPath":"/usr/local/var/mongodb"},"systemLog":{"destination":"file","logAppend":true,"path":"/usr/local/var/log/mongodb/mongo.log"}}}}
{"t":{"$date":"2023-06-03T14:30:42.769+08:00"},"s":"I",  "c":"NETWORK",  "id":5693100, "ctx":"initandlisten","msg":"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-06-03T14:30:42.769+08:00"},"s":"I",  "c":"NETWORK",  "id":5693100, "ctx":"initandlisten","msg":"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-06-03T14:30:42.770+08:00"},"s":"E",  "c":"CONTROL",  "id":20557,   "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"IllegalOperation: Attempted to create a lock file on a read-only directory: /usr/local/var/mongodb"}}

Btw, I tried using sudo brew services start mongodb-community and it worked but also got a warning that it's not recommended.

So I tried changing the permissions of /usr/local/var/mongodb with this command and this solved the error:

sudo chown -R `id -un` /usr/local/var/mongodb

Just an addtl info:

  • chown: command used to change the ownership of files and directories in Unix-like operating systems. The chown command allows you to specify a new owner for a given file or directory.
  • -R: It is an option for the chown command that stands for "recursive." When used, it instructs chown to operate recursively, changing the ownership of all files and directories within the specified directory and its subdirectories.
  • id -un: This is a command substitution enclosed within backticks. It executes the id -un command and substitutes its output as part of the overall command. The id -un command is used to retrieve the username of the current user. So, in this context, it fetches the username of the user executing the sudo command.
Mogerly answered 6/6, 2023 at 5:54 Comment(0)
N
0

finally got it to work again as non-root user.

  1. brew services stop mongodb-community or sudo brew services stop mongodb-community
  2. rm /opt/homebrew/var/log/mongodb/mongo.log
  3. brew services start mongodb-community
  4. cat /opt/homebrew/var/log/mongodb/mongo.log and look for any file and/or access errors
  5. fix the error (e.g. if the file or directory belongs to root, delete it, or change the owner)
  6. try restart brew services start mongodb-community
  7. cat /opt/homebrew/var/log/mongodb/mongo.log and look for any file and/or access errors again
  8. brew services stop mongodb-community
  9. fix the errors again
  10. GOTO 6

Loop until all errors are gone from /opt/homebrew/var/log/mongodb/mongo.log

Nuri answered 22/3, 2024 at 19:54 Comment(0)
T
-1

Solved

Changing the port number from 27017 to 27018 and restarting the service solved the issue

First edit the config file using sudo nano /opt/homebrew/etc/mongod.conf and add the port at the end of the file as the following and save it

systemLog:
  destination: file
  path: /opt/homebrew/var/log/mongodb/mongo.log
  logAppend: true
storage:
  dbPath: /opt/homebrew/var/mongodb
net:
  bindIp: 127.0.0.1, ::1
  ipv6: true
  port: 27018

And then restart brew services restart mongodb-community

Note: if your mac uses Intel Processor instead of Apple Silicon Processor then the path of the file would be /usr/local/etc/mongod.conf

Tractile answered 22/6, 2024 at 0:54 Comment(0)

© 2022 - 2025 β€” McMap. All rights reserved.