I am trying to start MongoDB but the terminal returns the following error:
2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] MongoDB starting : pid=25184 port=27017 dbpath=/data/db 64-bit host=Janiss-MacBook-Pro.local
2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] db version v3.4.1
2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] git version: 5e103c4f5583e2566a45d740225dc250baacfbd7
2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2k 26 Jan 2017
2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] allocator: system
2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] modules: none
2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] build environment:
2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] distarch: x86_64
2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] target_arch: x86_64
2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] options: {}
2017-02-06T16:26:27.038+0000 E NETWORK [initandlisten] listen(): bind() failed Address already in use for socket: 0.0.0.0:27017
2017-02-06T16:26:27.038+0000 E NETWORK [initandlisten] addr already in use
2017-02-06T16:26:27.038+0000 E NETWORK [initandlisten] Failed to set up sockets during startup.
2017-02-06T16:26:27.038+0000 E STORAGE [initandlisten] Failed to set up listener: InternalError: Failed to set up sockets
2017-02-06T16:26:27.038+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-02-06T16:26:27.038+0000 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-02-06T16:26:27.039+0000 I CONTROL [initandlisten] now exiting
2017-02-06T16:26:27.039+0000 I CONTROL [initandlisten] shutting down with code:48
I am using Laravel Valet if that matters.
It seems like you have already a process running on the port where you want to start mongodb:
listen(): bind() failed Address already in use for socket: 0.0.0.0:27017
2017-02-06T16:26:27.038+0000 E NETWORK [initandlisten] addr already in use
you could try to kill the process that runs on that port with this command:
sudo kill sudo lsof -t -i:27017
or define another port for mongodb if you have another program using that port.
to run mongodb on a port other than its default port (27017) use the --port 27018
argument when starting mongodb from the terminal
If you are using mac then you can simply kill the process running on port 27017
which is mongodb process in most cases.
Simply run the command.
npx kill-port 27017
After that you can run the mongod
command as you normally do.
Or if you are using windows follow these steps
netstat -ano | findstr :27017
taskkill /PID <typeyourPIDhere> /F
mongod
as you usually do!Enjoy!
Basically you just need to force quit the mongo, you can do this just by typing
sudo pkill -f mongod
and now you can start the server again with
mongod
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