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
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.