37

I am new to Ubuntu (Linux tbh). I encountered problem with starting MongoDB service. I want to created web app using Ruby on Rails and MongoDB but mongo seems to fail to start.

I followed this MongoDB installation on Ubuntu all of installation went without problems until I got to sudo service mongod start

mongod.log

2016-01-01T10:58:15.545+0000 I CONTROL  ***** SERVER RESTARTED *****
2016-01-01T10:58:15.548+0000 I CONTROL  [initandlisten] MongoDB starting : pid=3868 port=27017 dbpath=/var/lib/mongodb 64-bit host=damian-CX61-0NC-CX61-0ND-CX61-0NF-CX61-0NE
2016-01-01T10:58:15.548+0000 I CONTROL  [initandlisten] db version v3.0.8
2016-01-01T10:58:15.548+0000 I CONTROL  [initandlisten] git version: 83d8cc25e00e42856924d84e220fbe4a839e605d
2016-01-01T10:58:15.548+0000 I CONTROL  [initandlisten] build info: Linux ip-10-187-89-126 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2016-01-01T10:58:15.548+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2016-01-01T10:58:15.548+0000 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-01-01T10:58:15.567+0000 E NETWORK  [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-01-01T10:58:15.567+0000 I -        [initandlisten] Fatal Assertion 28578
2016-01-01T10:58:15.567+0000 I -        [initandlisten] 

***aborting after fassert() failure

So what I am doing wrong or its different issue?

Fresz
  • 1,804
  • 2
  • 16
  • 29
  • 10
    Does the file /tmp/mongodb-27017.sock exist? If so try to delete it, ie. 'sudo rm /tmp/mongodb-27017.sock'. – kometen Jan 01 '16 at 11:14
  • @kometen I think that worked - how to check that mongo is actually running? Like in windows I had cmd window with all these things going on - here I cant see any of it. Is mongod.log the only way to know what is going on? – Fresz Jan 01 '16 at 11:25
  • 2
    `ps ax | grep [m]ongod` – Markus W Mahlberg Jan 01 '16 at 11:58
  • I also think there is a 'service mongodb status'. – kometen Jan 01 '16 at 12:05
  • 2520 ? Sl 0:09 /usr/bin/gnome-terminal -x /bin/sh -c cd '/home/damian/Downloads/mongodb-linux-x86_64-ubuntu1404-3.2.0/bin' && exec $SHELL 3751 ? Sl 0:06 gedit /var/log/mongodb/mongod.log 4020 ? Ssl 0:23 /usr/bin/mongod --config /etc/mongod.conf 4206 pts/0 S+ 0:00 grep --color=auto mongo What does this mean? Am I running 4 different mongodb's at the same time? – Fresz Jan 01 '16 at 12:21
  • I'm not shure where the output came from. But there are probably more than one process to handle the requests. – kometen Jan 01 '16 at 19:19

9 Answers9

70

SOLUTION by kometen

Does the file /tmp/mongodb-27017.sock exist? If so try to delete it, ie. 'sudo rm /tmp/mongodb-27017.sock'.

Community
  • 1
  • 1
Fresz
  • 1,804
  • 2
  • 16
  • 29
8

The problem can also be due to mongodb using up all the disk space. That was the case for me. You can install ncdu with this command: sudo apt install ncdu

This will help you in looking at the disk usage. Use the command: ncdu -x /

Remove the unwanted dbs from /var/lib/mongodb/

minion
  • 81
  • 1
  • 3
7
sudo mongod

(suggested by @João Bortolosso)

after (suggested by @fresz):

sudo rm /tmp/mongodb-27017.sock

worked on mac!

Maya
  • 75
  • 1
  • 3
6

If you use Ubuntu, try:

sudo mongod
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
2

For me, it was because of the bad data inside the folder: ‘/data/db’

Solution that worked for me: Remove all the files inside '/data/db'

2

We was getting the same message in Production and service was not restarted

{"t":{"$date":"2021-08-18T15:18:27.834+00:00"},"s":"F",  "c":"-",        "id":23092,   "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}

So I ran this command (Giving the permission to mongodb user)

sudo chown mongodb:mongodb mongodb-27017.sock

And started the service

sudo systemctl start mongod

Now mongo is up and running. ;)

Credit Goes to our StackOverflow Contributor Rajith K

He gave the answer on 'Failed to unlink socket file" error in MongoDB 3.0

1
mongo --shell

It worked for me on ubuntu

Prince Agrawal
  • 380
  • 4
  • 14
0

You need to delete MongoDB temp file

sudo rm /tmp/mongodb-27017.sock

for any one getting this error after every restart, u need to stop mongod.service on startup

sudo systemctl disable mongod.service

the name mongod.service may change later, so just write mongo and press tab for autocompletion

0

clear the files inside c:\data\db folder and then start mongodb database using mongod command.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 14 '23 at 03:23