2

I had this problem before and was fixed by re-start the mongo again:

$ sudo systemctl start mongodb

But I am having this problem again and I have tried to re-start it as before. But it won't work this time!

$ mongo
MongoDB shell version: 3.2.6
connecting to: test
2017-03-29T10:48:44.306+0100 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2017-03-29T10:48:44.307+0100 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:229:14
@(connect):1:6

exception: connect failed

I have tried also:

1) Remove .lock file

sudo rm /var/lib/mongodb/mongod.lock 

2) repair the mongodb

mongod –repair

3) start the mongodb

$ sudo systemctl start mongodb

4) start the mongo client

$ mongo

... i get the same error above!

Any ideas what else I can do?

EDIT:

$ sudo systemctl status mongodb.service
● mongodb.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongodb.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2017-03-29 10:48:38 BST; 27min ago
  Process: 31841 ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf (code=exited, status=1/FAILURE)
 Main PID: 31841 (code=exited, status=1/FAILURE)

Mar 29 10:48:38 li1371-52.members.linode.com systemd[1]: Started High-performance, schema-free document-oriented database.
Mar 29 10:48:38 li1371-52.members.linode.com systemd[1]: mongodb.service: Main process exited, code=exited, status=1/FAILURE
Mar 29 10:48:38 li1371-52.members.linode.com systemd[1]: mongodb.service: Unit entered failed state.
Mar 29 10:48:38 li1371-52.members.linode.com systemd[1]: mongodb.service: Failed with result 'exit-code'.

EDIT 2:

$ mongod
2017-03-29T11:59:15.178+0100 I CONTROL  [initandlisten] MongoDB starting : pid=1014 port=27017 dbpath=/data/db 64-bit host=li1371-52.members.linode.com
2017-03-29T11:59:15.178+0100 I CONTROL  [initandlisten] db version v3.2.6
2017-03-29T11:59:15.178+0100 I CONTROL  [initandlisten] git version: 05552b562c7a0b3143a729aaa0838e558dc49b25
2017-03-29T11:59:15.178+0100 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2h  3 May 2016
2017-03-29T11:59:15.178+0100 I CONTROL  [initandlisten] allocator: tcmalloc
2017-03-29T11:59:15.178+0100 I CONTROL  [initandlisten] modules: none
2017-03-29T11:59:15.178+0100 I CONTROL  [initandlisten] build environment:
2017-03-29T11:59:15.178+0100 I CONTROL  [initandlisten]     distarch: x86_64
2017-03-29T11:59:15.178+0100 I CONTROL  [initandlisten]     target_arch: x86_64
2017-03-29T11:59:15.178+0100 I CONTROL  [initandlisten] options: {}
2017-03-29T11:59:15.204+0100 E NETWORK  [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2017-03-29T11:59:15.204+0100 I -        [initandlisten] Fatal Assertion 28578
2017-03-29T11:59:15.204+0100 I -        [initandlisten] 

***aborting after fassert() failure

EDIT 3:

$ sudo mongod
2017-03-29T12:05:54.159+0100 I CONTROL  [initandlisten] MongoDB starting : pid=4075 port=27017 dbpath=/data/db 64-bit host=li1371-52.members.linode.com
2017-03-29T12:05:54.159+0100 I CONTROL  [initandlisten] db version v3.2.6
2017-03-29T12:05:54.159+0100 I CONTROL  [initandlisten] git version: 05552b562c7a0b3143a729aaa0838e558dc49b25
2017-03-29T12:05:54.159+0100 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2h  3 May 2016
2017-03-29T12:05:54.159+0100 I CONTROL  [initandlisten] allocator: tcmalloc
2017-03-29T12:05:54.159+0100 I CONTROL  [initandlisten] modules: none
2017-03-29T12:05:54.159+0100 I CONTROL  [initandlisten] build environment:
2017-03-29T12:05:54.159+0100 I CONTROL  [initandlisten]     distarch: x86_64
2017-03-29T12:05:54.159+0100 I CONTROL  [initandlisten]     target_arch: x86_64
2017-03-29T12:05:54.159+0100 I CONTROL  [initandlisten] options: {}
2017-03-29T12:05:54.185+0100 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2017-03-29T12:05:54.185+0100 I CONTROL  [initandlisten] dbexit:  rc: 100
piet.t
  • 11,718
  • 21
  • 43
  • 52
Run
  • 54,938
  • 169
  • 450
  • 748
  • try `sudo systemctl status mongodb.service` that might give you better idea on why it is crashing in the first place :) – georoot Mar 29 '17 at 09:59
  • @georoot thanks. please see my edit above. can you see what is causing it? – Run Mar 29 '17 at 10:08
  • `--quiet` flag is suppressing errors. Directly run `mongod` from terminal command is `mongod --config /etc/mongodb.conf` – georoot Mar 29 '17 at 10:12
  • @georoot sorry I don't understand what I should do now. use `--quiet` with what? – Run Mar 29 '17 at 10:17
  • when I run `$ sudo mongod --config /etc/mongodb.conf` i get nothing in return. – Run Mar 29 '17 at 10:21
  • I mean that the systemCtl is using `--quiet` flag which is suppressing the warnings. Also what is the status code you are getting from `mongod` ? – georoot Mar 29 '17 at 10:31
  • Have you tried restarting the service with: `sudo systemctl restart mongodb.service` – ArchNoob Mar 29 '17 at 10:39
  • Also, have you seen this : http://stackoverflow.com/questions/24899849/connection-refused-to-mongodb-errno-111?rq=1 and a bunch of other related questions with same issue.. – ArchNoob Mar 29 '17 at 10:42
  • @ArchNoob I have tried `sudo systemctl restart mongodb.service` but still no luck. – Run Mar 29 '17 at 10:48
  • @georoot please see my edit 2. – Run Mar 29 '17 at 10:49
  • @teelou you forgot `sudo` while running `mongod` its showing `unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted` – georoot Mar 29 '17 at 10:54
  • @teelou its long discussion lets just move it to chat :) – georoot Mar 29 '17 at 10:55
  • http://chat.stackoverflow.com/rooms/info/139352/chat-with-teelou?tab=general – georoot Mar 29 '17 at 10:56

1 Answers1

3

I restarted mongodb service using brew and it helped:

brew services stop mongodb
brew services start mongodb
Grzegorz Pawlik
  • 2,198
  • 1
  • 18
  • 18