Error message:
Listen (): Bind () failed errno:48 Address already in use for socket:0.0.0.0:27017
Port 27017 is already occupied
Complete error information
2016-10-24t23:46:56.314+0800 E NETWORK [Initandlisten] Listen (): Bind () failed errno:48 Address already in use for socket : 0.0.0.0:27017
2016-10-24t23:46:56.314+0800 E NETWORK [Initandlisten] addr already in use
2016-10-24t23:46:56.314+0800 E STORAGE [Initandlisten] Failed to set up sockets during startup.
2016-10-24t23:46:56.314+0800 I CONTROL [Initandlisten] dbexit:rc:48
Processing method: Input in Terminal:
PS aux | grep Mongod
Locate the corresponding process ID and kill:
Kill-9 PID
Such as
Execute the mongod command again to open the MongoDB service
Workaround under window:
http://stackoverflow.com/questions/34709062/failed-to-set-up-sockets-during-startup-dbexit-rc-48-error-in-mongodb/35650275
Find the process running on port 27017:
C:\Users\hughes> netstat -aon | findstr 27017 TCP 0.0.0.0:27017 0.0.0.0:0 LISTENING 3344
The last column shows the PID (3344). Find the process name for this PID:
C:\users\hughes>Tasklist/Fi"PID eq 3344"Image NamePidsession name session< Span class= "pun" ># mem usage ========================= ======== ================ =========== ============virtualbox . exe 3344 console 1 101,908 K
For me it turned out that VirtualBox's port forwarding was the issue.
Mongod command execution discovers that there is already a process running Mongod database--errno:48 Address already in use for socket:0.0.0.0:27017