error starting mongodb with brew start on macOS Catalina 10.15.6

Viewed 153

I have tried a few troubleshoots to no avail. They don't seem to match my specific error. I start mongodb with

> brew services start mongodb-community

The terminal says it is succesfully started, but when i

> brew services

to check mongodb's status it says error. No explanation. But if I open up a new terminal and run mongo, I do however get a more detailed error.

> connecting to: mongodb://127.0.0.1:27017/? 
> compressors=disabled&gssapiServiceName=mongodb
> Error: couldn't connect to server 127.0.0.1:27017, connection 
> attempt failed: SocketException: Error connecting to 
> 127.0.0.1:27017 :: caused by :: Connection refused :
1 Answers

I have found a solution to this problem. The socket exception error is apparently being thrown because the root owns the

/tmp/mongodb-27017.sock 

solution

sudo rm -rf /tmp/mongodb-27017.sock

re start mongodb with

brew services start mongodb-community@4.4

it will create a new

/tmp/mongodb-27017.sock

which is owned by user. You can check by

ls -lsah /tmp/mongodb-27017.sock

my output was then

0 srwx------  1 userName  wheel     0B Apr  8 12:05 /tmp/mongodb-27017.sock

where username was previously root.

my solution was found here https://stackoverflow.com/a/62196227/15311479

Related