MongoDB server with OS Catalina

Viewed 3813

I upgrade my Mac OS to Catalina and now my server is not working well. I reinstalled all the system from scratch and reinstall with brew, however when trying to connect to Mongo website learning database the system does not allow through the shell. It returns in the end of the body the following message: "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":48}

4 Answers

I don't know about MAC OS but I faced the same issue on my Ubuntu 20.04 recently. I was trying to run the mongodb server on local machine using a specified path data which is a directory(folder). But it was giving me the same exitcode:48 as mentioned by you. I solved it by stopping the mongod server running on my system using the command:

sudo systemctl stop mongod

And then executed the command:

mongod --dbpath=data --bind_ip 127.0.0.1

You already tried to specify another port?

Like mongo shell: mongod --port 27018

With the following code, on Terminal you can find PID for mongodb and kill it:

lsof -i :27017 | awk '{print $2}' | tail -n 1 | xargs kill -9

The default mongodb port number is 27017. You can change it if you have another mongodb port number.

FYI, awk, tail are just extracting the PID number for the given port and, if it exists, then it goes and terminates it.

In my case, I went through the error, and found it was due to the permission issue for,

  1. data/db folder creation

  2. it was not able to open the socket. Fixed it by below

  3. created the data/db folder in my convenient directory, ie in my common codebase folder

> mkdir data && cd data && mkdir db

> pwd

/User/{uname}/codebase/data/db

mongob --dbpath="/User/{uname}/codebase/data/db"

Related