i found this error when trying to run mongodb. I install it via homebrew. Please assist
Agungs-MacBook-Pro:~ agungmahaputra$ mongod
2017-12-26T15:31:15.911+0
if you're using mongodb version 4.*
in default settings, there should be a "db" folder "/data/db" having the necessary permission.
to check it the MongoDB service started
brew services list
if not then run
brew services start mongodb
run mongo instead of mongod
First, shutdown the running server using:
mongod --shutdown
Then run:
sudo mongod
I solved it pasting the command below into the command line in order to close mongo's server.
sudo pkill -f mongod
"sudo" (Super User Do) runs the command admin permissions, so it will ask you for your user password
If your mongod process is already down, just remove the .sock file in /tmp:
My mongod is already down, so does not appears in:
lsof -iTCP -sTCP:LISTEN -n -P
The error was:
[root@ol7db19c1 ~]# mongod -f /etc/csrs_2.conf
about to fork child process, waiting until server is ready for connections.
forked process: 6721
ERROR: child process failed, exited with error number 48
To see additional information in this output, start without the "--fork" option.
In the log file (/var/mongodb/db/csrs2.log):
2020-07-05T16:03:59.354-0300 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
So, find for the socket locking:
ls -ltra /tmp|grep .sock
And just remove it (do it with caution in production environment):
rm -f mongodb-26002.sock
G-luck!
After running this commands below:
sudo lsof -iTCP -sTCP:LISTEN -n -P
Search for mongod COMMAND and its PID and type,
sudo kill <mongo_command_pid>
And restarting mongod, it still fails with the same error "SocketException: Address already in use MONGODB".
Server was restarted yesterday and then this happened.