0

I just installed MongoDb on Ubuntu 16.04 and I can not run the server. I get the following information when the "status" of the server (sudo systemctl start mongodb):

lmunoz@lmunoz:/var/www/node/dashboard$ sudo systemctl status mongodb
● mongodb.service - High-performance, schema-free document-oriented 
database
Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor 
preset: enabled)
Active: failed (Result: exit-code) since mar 2017-05-09 12:01:59 PET; 
29s ago
Process: 1042 ExecStart=/usr/bin/mongod --quiet --config 
/etc/mongod.conf (code=exited, status=48)
Main PID: 1042 (code=exited, status=48)

may 09 12:01:59 lmunoz systemd[1]: Started High-performance, schema-
free document-oriented database.
may 09 12:01:59 lmunoz systemd[1]: mongodb.service: Main process 
exited, code=exited, status=48/n/a
may 09 12:01:59 lmunoz systemd[1]: mongodb.service: Unit entered 
failed state.
may 09 12:01:59 lmunoz systemd[1]: mongodb.service: Failed with result 
'exit-code'.

The log (/var/log/mongodb/mongod.log) shows me the following:

listen(): bind() failed errno:98 Address already in use for socket: 
127.0.0.1:27017
addr already in use
Failed to set up sockets during startup.
dbexit:  rc: 48

And my configuration file (/etc/systemd/system/mongodb.service) contains:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target
Luis
  • 2,006
  • 5
  • 31
  • 47
  • Possible duplicate of [unable to start mongodb local server](http://stackoverflow.com/questions/6478113/unable-to-start-mongodb-local-server) – Bor Laze May 09 '17 at 17:22

1 Answers1

2

Look at the logs you are having another service which is running on the port 27017.

Look for that service and stop it and then retry. Or if you don't care about the service running on that port, can do

sudo fuser -k 27017/tcp

Another alternative will be to change the default of mongodb. See mongodb how to change default port

Community
  • 1
  • 1
berrytchaks
  • 839
  • 10
  • 18