Mongodb-community@5.0 always fails to restart on Mac following unclean shutdown/reboot

Back in September I updated my homebrew install of mongodb community from v4.2 to v5.0.21 on my M2 Max Mac (currently running macOS 14.1.1) and ever since then if I have to restart following an issue with my Mac (which will typically be a problem with DisplayLink Manager) monogodb-community fails to start properly

It seems to be some sort of permissions issue… at least I know that if I do the following steps it resolves the problem and mongodb then starts OK:

  1. delete /tmp/mongodb-27017.sock (when the issue occurs the owner of the file seems to end up being root/wheel instead of me/wheel)
  2. run sudo chown -R $(whoami) $(brew --prefix)/*
  3. run brew services restart mongodb-community@5.0

But obviously it’s really annoying having to do this whenever the problem occurs so I’m just wondering if there’s something I can do to fix it?

I do have a snapshot of my mongodb.log from around the time the problem occurs to the point where I successfully get it restarted - but unfortunately as a new user here I don’t have permission to upload files in posts yet :frowning:

One interesting thing I do notice is that in the logs it says ‘You are running this process as the root user, which is not recommended’ - but I’m not sure if a) this is the source of the problem or b) how to fix it if it is

Any help/recommendations gratefully received!

You should not start mongod as root
That may be the reason why your tmp sock file is having root ownership
How is your mongod configured to start?auto or manual
After reboot do you start it manually?
If yes as what user?

@Ramachandra_Tummala thanks for taking the time to reply and for confirming my suspicions that running mongod as root user might be the source of the issue.

I’m running mongodb via brew services. I just ran brew services list and noted that it was running the service as root. I am not sure why it was doing that as I don’t recall ever having used sudo to start it - but I have run sudo brew services stop mongodb-community@5.0 to stop it then brew services start mongodb-community@5.0 to start it again as me. I then restarted to check that it was still being started under my user account - which it is.

Hopefully that will resolve the issue… not much I can do really except wait until I have to do another ‘unclean’ restart and see what happens after that. But at the very least this has all got me closer to understanding why the problem occurs so many thanks for that!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.