error 48 is a new error for me.
i'm also getting the error when trying to enter mongo
Error: network error while attempting to run command 'isMaster' on host '127.0.0.1:27017'
v3.2.10
git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
allocator: tcmalloc
modules: none
build environment:
distmod: ubuntu1604
distarch: x86_64
target_arch: x86_64
i try starting mongo with
sudo mongod --fork --port 27017 --replSet replset --logpath ~/log/mongo.log
just kill the mongod process first
ps -ef | grep mongod
sudo kill -9 {processid}
then run the command.
You can try the following steps to restart the process:
pidof mongod
sudo kill -9 {pidOfRunningMongod}
sudo mongod --fork --auth --port 27018 --dbpath /data/db --logpath /var/log/mongod.log
Worked for me
What does the log file says? This error usually comes when there is a process already running with the port number you are using to start mongod process with, which is 27017 here.
You can run the below command to check the spid which is using the port
netstat -ntulp|grep 27017
I took used to get similar error (error no. 48). I usually run like this:
mongod --config /apps/data/appdb/appdb.conf --fork
In my "appdb.conf" there is a parameter called "Bind Address" which was pointing to "0.0.0.0" and I simply changed it to actual IP of the server/machine (which can be found if you run hostname -i command). Saved the file and tried the above "fork" command and worked like a charm. Hope this helps.
First of all, for the first answer, you should not kill a Mongodb process with -9.
See use kill section in following documentation: https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/
Maybe try to find and delete mongod.pid
(/your/path/mongodb/mongod.pid) and restart Mongodb again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With