homebrew - MongoDB won't run on new MBP after restart - Stack Overflow

admin2025-04-16  7

I have a new MBP, and originally set my dev env up with MongoDB installed with homebrew and running fine. It was set to start up on login with brew services start [email protected]. Today I restarted my mac and now I can't start mongodb...

I tried uninstalling/reinstalling with brew, and also tried uninstalling/reinstalling homebrew and starting afresh - all with the same results.

If I brew services start [email protected] I get the expected output confirming the service has started, if I then run brew services list I get the following output:

Name                  Status      User File
[email protected] error  3584 code ~/Library/LaunchAgents/[email protected]

and mongosh returns

Current Mongosh Log ID: 67a1440b69dce9d92aa73446
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.3.8
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017

I was tired when I started trying to fix, and homebrew suggested running some commands with sudo, so I'm wondering if I've messed up my permissions somewhere, and they're still hanging around affecting reinstalls?

Can someone help me troubleshoot this? I really don't know where to go from here, I need mongodb 5.0 up and running, and I'm getting to the point of resetting my mac back to factory settings and starting from scratch again, but I'd rather understand the problem and the fix :)

Will happily supply any and all info requested.

Many thanks

I have a new MBP, and originally set my dev env up with MongoDB installed with homebrew and running fine. It was set to start up on login with brew services start [email protected]. Today I restarted my mac and now I can't start mongodb...

I tried uninstalling/reinstalling with brew, and also tried uninstalling/reinstalling homebrew and starting afresh - all with the same results.

If I brew services start [email protected] I get the expected output confirming the service has started, if I then run brew services list I get the following output:

Name                  Status      User File
[email protected] error  3584 code ~/Library/LaunchAgents/[email protected]

and mongosh returns

Current Mongosh Log ID: 67a1440b69dce9d92aa73446
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.3.8
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017

I was tired when I started trying to fix, and homebrew suggested running some commands with sudo, so I'm wondering if I've messed up my permissions somewhere, and they're still hanging around affecting reinstalls?

Can someone help me troubleshoot this? I really don't know where to go from here, I need mongodb 5.0 up and running, and I'm getting to the point of resetting my mac back to factory settings and starting from scratch again, but I'd rather understand the problem and the fix :)

Will happily supply any and all info requested.

Many thanks

Share Improve this question asked Feb 3 at 23:08 paul hpaul h 3243 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

OK, I ran mongod and from the error output it appeared that the culprit was /tmp/mongodb-27017.sock from the following error:

{"t":{"$date":"2025-02-03T23:13:06.391+00:00"},"s":"E",  "c":"NETWORK",  "id":23024,   "ctx":"initandlisten","msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Permission denied"}}

So I removed the socket file, uninstalled and reinstalled mongodb, and now mongosh connects as expected.

转载请注明原文地址:http://www.anycun.com/QandA/1744746030a87022.html