Error message while starting the mongoDB service. Error:

Permission denied @ rb_sysopen - /Users/syedahmed/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

I installed/reinstall the mongoDB couple times. But I am getting same problem

" error : permission denied"

I am using the [email protected] edition in Mac OS Mojave 10.14

I have tried different ways after reading suggestions in stack overflow but nothing has worked.

I have installed following the instruction from mongoDB.

The services doesn't start.

how to config the username and password using config? I am not sure.

while installing from brew it did not ask for config any password or username.

brew services start [email protected]

if I start service typing just: mongo Following error message comes:

MongoDB shell version v4.2.0 connecting to: mongodb:// 2019-09-01T23:23:31.392-0400 E QUERY [js] Error: couldn't connect to server, connection attempt failed: SocketException: Error connecting to :: caused by :: Connection refused : connect@src/mongo/shell/mongo.js:341:17 @(connect):2:6 2019-09-01T23:23:31.397-0400 F - [main] exception: connect failed 2019-09-01T23:23:31.397-0400 E - [main] exiting with code 1 –

  • Have you noticed the Permission denied in the error messages? Sep 2, 2019 at 17:42
  • is this port number available: Error connecting to :: caused by :: Connection refused Sep 2, 2019 at 17:43
  • I am using the MacOS Mojave 10.14.5. I have installed using the brew. It goes to default folder. Even if you try with other version it also doesn't allow to access.
    – Syed Ahmed
    Sep 2, 2019 at 21:14

3 Answers 3


use code below before mongo

sudo brew services start mongodb-community

My solution is here:

  1. Make a directory as - sudo mkdir -p /data/db
  2. That will make a directory named as db and than try to start with commands - sudo mongod

Had the same problem and it could be due to your service not being able to create the socket (check with netstat -an | grep 27017 if you have it up properly)

What I did:

Create a properly placed data/db on System/Volumes/Data/data/db, with

sudo mkdir -p /System/Volumes/Data/data/db
sudo chown -R `id -un` /System/Volumes/Data/data/db

And, then, add that path to mongod.conf (located on /usr/local/etc/mongod.conf), replacing dbPath there:

  dbPath: /System/Volumes/Data/data/db

Then, restart it. If you are using brew, do:

brew services restart mongodb-community

Source: https://zellwk.com/blog/install-mongodb/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.