aborting after fassert() failure On Mac - node.js

I am creating an express app with Nodejs & MongoDB, this is my first time.
When I run this command,
mongod --dbpath SM:NodeTestApp101\data
I am getting this error
015-11-08T08:24:01.771-0700 E NETWORK [initandlisten] Failed to
unlink socket file /tmp/mongodb-27017.sock errno:13 Permission denied
2015-11-08T08:24:01.771-0700 I - [initandlisten] Fatal
Assertion 28578
2015-11-08T08:24:01.771-0700 I - [initandlisten]
***aborting after fassert() failure
I am new with MongoDB and have no idea what it means, I have google it and have had no luck solving this issue.
Is there anyone that can help me with it? I can provide more information if needed, Please just let me know.

Related

Impossible to connect to mongo after server shutdown

I am running a mongo cluster (v 3.4.1) on a remote Ubuntu server. This server had an unexpected shutdown yesterday. Since that, I cannot connect to mongo.
I connected by ssh to the server to check if mongo was running. It seems to be the case because if I use the mongo command, I get the following output:
MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.1
Server has startup warnings:
2017-09-28T08:01:43.906+0000 I STORAGE [initandlisten]
2017-09-28T08:01:43.906+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-09-28T08:01:43.906+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-09-28T08:01:44.204+0000 I CONTROL [initandlisten]
2017-09-28T08:01:44.204+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-09-28T08:01:44.204+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-09-28T08:01:44.204+0000 I CONTROL [initandlisten]
Now if I run "mongod" I get the exception:
...
2017-09-28T10:10:26.065+0200 I STORAGE [initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating
2017-09-28T10:10:26.065+0200 I NETWORK [initandlisten] shutdown: going to close listening sockets...
...
I tried in sudo mode, I got:
...
2017-09-28T10:12:21.857+0200 E NETWORK [initandlisten] listen(): bind() failed Address already in use for socket: 0.0.0.0:27017
2017-09-28T10:12:21.857+0200 E NETWORK [initandlisten] addr already in use
2017-09-28T10:12:21.857+0200 E NETWORK [initandlisten] Failed to set up sockets during startup.
2017-09-28T10:12:21.857+0200 E STORAGE [initandlisten] Failed to set up listener: InternalError: Failed to set up sockets
2017-09-28T10:12:21.857+0200 I NETWORK [initandlisten] shutdown: going to close listening sockets...
...
Which would mean that an instance of mongo is already running...
Then I tried to kill mongo process, either with sudo service mongod stop or sudo pkill mongod or sudo kill <PID> after listing processes with ps -ef | grep mongo. But the process does not disappear from the list (seems that it restarts immediately).
So if I try to run sudo mongod --dbpath /data/db --repair (there is a mongod.lock file in the directory), I still get the error "Address already in use".
Any help would be really appreciated!

Error while Recovering a WiredTiger collection from a corrupt MongoDB installation

We have implemented MongoDB master-slave replication and database got deleted.
We restored deleted files from Mongo data directory using extundelete command.
Undelete Blog https://github.com/RIKSOF/development/wiki/Restoring-deleted-files-on-Linux
We wanted to restore at least one collection for which we got the WT (wired timer) file. We are trying to restore that file using the following commands and we are getting the following errors
Recovering a WiredTiger collection from a corrupt MongoDB installation
wget http://source.wiredtiger.com/releases/wiredtiger-2.7.0.tar.bz2
tar xvf wiredtiger-2.7.0.tar.bz2
cd wiredtiger-2.7.0
sudo apt-get install libsnappy-dev build-essential
./configure --enable-snappy
make
./wt -v -h ../mongo-bak -C "extensions=[./ext/compressors/snappy/.libs/libwiredtiger_snappy.so]" -R salvage collection-2657--1723320556100349955.wt
Error -
./wt -v -h ../mongo-bak -C "extensions=[./ext/compressors/snappy/.libs/libwiredtiger_snappy.so]" -R salvage collection-246--7553069514495955510.wt
[1488888117:36780][13536:0x7f7b633cd740], file:WiredTiger.wt, connection: read checksum error for 4096B block at offset 12288: block header checksum of 1955562709 doesn't match expected checksum of 3146787951
[1488888117:36809][13536:0x7f7b633cd740], file:WiredTiger.wt, connection: WiredTiger.wt: encountered an illegal file format or internal value
[1488888117:36817][13536:0x7f7b633cd740], file:WiredTiger.wt, connection: the process must exit and restart: WT_PANIC: WiredTiger library panic
lt-wt: WT_PANIC: WiredTiger library panic
This could be related to corrupted .wt files (e.g. WiredTiger.wt/WiredTiger.turtle) as per SERVER-31076 bug report.
Try to run repair on all databases by the following command:
mongod --repair --dbpath /path/to/data/db
Also make sure all data/db files have the right read and write permission.
In my case, I had recovered mac from Time Machine. I had mongodb installed via brew install. When I started mongo, the service did not start cleanly.
vi /usr/local/var/log/mongodb/mongo.log
enter code here
2020-01-30T17:06:10.655-0500 E STORAGE [initandlisten] WiredTiger error (0) [1580421970:655376][62181:0x112233dc0], file:WiredTiger.wt, connection: __wt_block_read_off, 283: WiredTiger.wt: read checksum error for 4096B block at offset 12288: block header checksum of 0x325e318 doesn't match expected checksum of 0x65ef0e12 Raw: [1580421970:655376][62181:0x112233dc0], file:WiredTiger.wt, connection: __wt_block_read_off, 283: WiredTiger.wt: read checksum error for 4096B block at offset 12288: block header checksum of 0x325e318 doesn't match expected checksum of 0x65ef0e12
What I saw was that because of a corrupt mongodb collection.
So, I ran the cleanup command for the brew install, which has the db in a different location.
mongod --repair --dbpath /usr/local/var/mongodb
2020-01-30T17:06:11.741-0500 I STORAGE [initandlisten] Verify failed on uri table:collection-12--8361386101775862971. Running a salvage operation.
2020-01-30T17:06:11.745-0500 I STORAGE [initandlisten] Repairing collection wlchat.jobs
2020-01-30T17:06:11.765-0500 I STORAGE [initandlisten] WiredTiger progress WT_SESSION.verify 100
2020-01-30T17:06:11.769-0500 I STORAGE [initandlisten] WiredTiger progress WT_SESSION.verify 200
2020-01-30T17:06:11.774-0500 I STORAGE [initandlisten] WiredTiger progress WT_SESSION.verify 300
2020-01-30T17:06:11.783-0500 I STORAGE [initandlisten] WiredTiger progress WT_SESSION.verify 400
2020-01-30T17:06:11.789-0500 I STORAGE [initandlisten] WiredTiger progress WT_SESSION.verify 500
2020-01-30T17:06:11.793-0500 I STORAGE [initandlisten] WiredTiger progress WT_SESSION.verify 600
2020-01-30T17:06:11.795-0500 I STORAGE [initandlisten] Verify succeeded on uri table:collection-10--8361386101775862971. Not salvaging.
2020-01-30T17:06:11.795-0500 I STORAGE [initandlisten] Repairing collection wlchat.SovrenJobs
2020-01-30T17:06:11.801-0500 I STORAGE [initandlisten] Verify succeeded on uri table:collection-0-8794251073515214768. Not salvaging.
2020-01-30T17:06:11.814-0500 I INDEX [initandlisten] index build: starting on wlchat.users properties: { v: 2, key: { _id: 1 }, name: "_id_", ns: "wlchat.users" } using method: Foreground
and restart mongodb-community
brew services restart mongodb-community.
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)
Things are back to normal.
I got this error and trying a lot of way to resolve but not reached to successfully.
I am currently using 5.0.1 mongodb standalone version,
removed currently installed mongodb ( 5.0.1 )
installed latest version ( 6.0 )
and reapaired all corrupted *.wt file and verified.
mongod --repair --dbpath /path/to/data/db

Mongodb won't start - reason: errno:111 Connection refused

All of a sudden I can't get mongodb to work.
Usually I will start with
mongo
however I get this when trying to start.
MongoDB shell version: 3.0.6
connecting to: test
2016-10-11T15:36:56.462+0100 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-10-11T15:36:56.464+0100 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
I haven't updated anything on the server or even logged into it until the website broke. Any ideas why this is happening? I have tried to comment out the bind_ip but I don't get why it would just stop working and failing to start.
I have also tried
sudo service mongo start
mongod start/running, process 1529
Then when I tried -
sudo service mongod status
mongod stop/waiting.
I can't start my nodejs app because it returns
/node_modules/mongoose/node_modules/mongodb/lib/server.js:22‌​8 process.nextTick(function() { throw err; }) ^ Error: connect ECONNREFUSED at exports._errnoException (util.js:746:11) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
I think that is because mongodb isn't starting correctly but not sure.
The error produces this
2016-10-11T15:40:30.400+0100 E JOURNAL [initandlisten] Insufficient free space for journal files
2016-10-11T15:40:30.400+0100 I JOURNAL [initandlisten] Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
2016-10-11T15:40:30.400+0100 I JOURNAL [initandlisten]
2016-10-11T15:40:30.402+0100 I STORAGE [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
2016-10-11T15:40:30.402+0100 I CONTROL [initandlisten] now exiting
2016-10-11T15:40:30.402+0100 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2016-10-11T15:40:30.402+0100 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2016-10-11T15:40:30.402+0100 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2016-10-11T15:40:30.402+0100 I NETWORK [initandlisten] shutdown: going to close sockets...
2016-10-11T15:40:30.402+0100 I STORAGE [initandlisten] shutdown: waiting for fs preallocator...
2016-10-11T15:40:30.402+0100 I STORAGE [initandlisten] shutdown: final commit...
2016-10-11T15:40:30.402+0100 I STORAGE [initandlisten] shutdown: closing all files...
2016-10-11T15:40:30.402+0100 I STORAGE [initandlisten] closeAllFiles() finished
2016-10-11T15:40:30.402+0100 I CONTROL [initandlisten] dbexit: rc: 100
2016-10-11T15:45:36.614+0100 I CONTROL ***** SERVER RESTARTED *****
2016-10-11T15:45:36.642+0100 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-10-11T15:45:36.642+0100 I - [initandlisten] Fatal Assertion 28578
2016-10-11T15:45:36.642+0100 I - [initandlisten]
***aborting after fassert() failure
2016-10-11T15:46:21.636+0100 I CONTROL ***** SERVER RESTARTED *****
2016-10-11T15:46:21.663+0100 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-10-11T15:46:21.663+0100 I - [initandlisten] Fatal Assertion 28578
2016-10-11T15:46:21.663+0100 I - [initandlisten]
I broswed to that dir and saw this!!! Why are those files so huge?
It seems that your error is similar to this
Removing the /tmp/mongodb-27017.sock file should do the trick.
Also check your disk space, as it seems the process is not starting because you are missing space for the journal files (check #dave-v comment below)
i open file /etc/mongodb.conf and put a # in begin of line bind_ip = 127.0.0.1 (#bind_ip = 127.0.0.1) .Then restart mongodb, it's work fine again !
Warning: If you use mongodb in online server, please don't do that. Hacker can attack for this port !
I faced same issue , solution is here
1) Once the mongo installation done by downloading or yum install
2) Create folder db under /home/scc-dev/data/db/
3)Goto mongo folder under bin , open terminal run the below command
sudo ./mongod dbpath /home/scc-dev/data/db
4)Check few lines command running in the console
5)open new terminal under bin run the below command
sudo ./mongo
6) type command -> show dbs (it should show default dbs like local..) then it is working fine
7) if you get error like Failed to connect to 127.0.0.1:27017, reason: errno: 61 Connection refused then
8) restart the linux m/c command - > /sbin/reboot (do the steps from 3 - issue will be resolved )
To open the any ports in linux m/c
sudo iptables -I INPUT -p tcp -m tcp --dport 27017 -j ACCEPT
sudo iptables-save

MongoDB Data directory /data/db not found [duplicate]

This question already has answers here:
Mongod complains that there is no /data/db folder
(28 answers)
Closed 7 years ago.
When I try to run Mongod in terminal I got this message :
2015-05-14T17:33:04.554+0700 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2015-05-14T17:33:04.554+0700 I CONTROL [initandlisten] dbexit: rc: 100
and running mongo command :
MongoDB shell version: 3.0.3
connecting to: test
2015-05-14T17:34:26.679+0700 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-05-14T17:34:26.681+0700 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
I Have tried to change permision in /var/lib/mongodb and /var/log/mongodb, but still doesnt work, and I tried to uninstall and install mongodb again, but still the same problem exist.
Anyone could help? Thanks
I'm using Ubuntu 14.04 LTS 64 bit
MongoDB needs data directory to store data.
Default path is /data/db
When you start MongoDB engine, it searches this directory which is missing in your case. Solution is create this directory and assign rwx permission to user.
If you want to change the path of your data directory then you should specify it while starting mongod server like,
mongod --dbpath /data/<path> --port <port no>
This should help you start your mongod server with custom path and port.

Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused

while trying this mongo command in ubuntu
I am getting this error.
ritzysystem#ritzysystem-Satellite-L55-A:~$ mongo
MongoDB shell version: 2.6.1
connecting to: test
2014-10-06T12:59:35.802+0530 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2014-10-06T12:59:35.802+0530 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
how can I rectify this is anyone had the same problem.
Run the following command :
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongod restart
Connection refused to MongoDB errno 111
MacOS:
rm /usr/local/var/mongodb/mongod.lock
sudo service mongod restart
I had the same problem on Mac OS
Try to run sudo mongod and in a new terminal tab run mongo
thank you everyone I tried running mongo it was not running finally I found there was no space in my hard disc I emptied some of the space and finally re installed it the same installation procedure as followed to install as given in mongodb docs finally restarted the server and it is running.
https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu
In my case the error was due to missing /data/db folder which the mongodb uses to store your data. Please type this command $sudo mongod in your terminal. If the error message is something like :
missing data/db folder error
Simply create the folder and you are good to go.
First,
Start MongoDB:
sudo service mongod start
Then, Run:
mongo
Probably you don't have space in your hard drive.
Check it by typing in the promt df -h
Please note that mongo might fail even with 3gb available in the corresponding partition. For details, you might want to check the log: cat /var/log/mongodb/mongod.log
Make sure you have run the MongoDB's Service before you want to connect the console.
run and start the server:
$ sudo mongod
then:
$ mongo
...
>
I had the same problem on my Mac, and I installed mongodb via homebrew. I solve this problem by the homebrew services command.
First start mongodb service:
$ brew services start mongodb
Start mongodb terminal
$ mongo
Stop mongodb service:
$ brew services stop mongodb
Do this:
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongod restart
If you are on Ubuntu 16.04 which you can figure out by runnign this:
lsb_release -a
You need to Create a new file at /lib/systemd/system/mongod.service with the following contents:
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
In my case the problem was caused due to an apparent lost of permission over mongodb.lock file. I could solve the problem changing the permission with the following command :
sudo chown mongodb:mongodb /var/lib/mongodb/mongodb.lock
There follows my investigation:
I think except for disk space issuse, you should check the log in /var/log/mongodb to know the details for why mongodb start failed.
cat /var/log/mongodb/mongod.log
2016-06-26T15:26:26.642+0800 I CONTROL [main] ***** SERVER RESTARTED *****
2016-06-26T15:26:26.649+0800 I CONTROL [initandlisten] MongoDB starting : pid=8130 port=27017 dbpath=/var/lib/mongodb 64-bit host=hadoop-master
2016-06-26T15:26:26.649+0800 I CONTROL [initandlisten] db version v3.2.7
2016-06-26T15:26:26.649+0800 I CONTROL [initandlisten] git version: 4249c1d2b5999ebbf1fdf3bc0e0e3b3ff5c0aaf2
2016-06-26T15:26:26.649+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-06-26T15:26:26.649+0800 I CONTROL [initandlisten] allocator: tcmalloc
2016-06-26T15:26:26.649+0800 I CONTROL [initandlisten] modules: none
2016-06-26T15:26:26.649+0800 I CONTROL [initandlisten] build environment:
2016-06-26T15:26:26.649+0800 I CONTROL [initandlisten] distmod: ubuntu1404
2016-06-26T15:26:26.649+0800 I CONTROL [initandlisten] distarch: x86_64
2016-06-26T15:26:26.649+0800 I CONTROL [initandlisten] target_arch: x86_64
2016-06-26T15:26:26.649+0800 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1,192.168.3.10", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-06-26T15:26:26.678+0800 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-06-26T15:26:26.678+0800 I - [initandlisten] Fatal Assertion 28578
2016-06-26T15:26:26.678+0800 I - [initandlisten]
***aborting after fassert() failure
So, here I need to rm all the files in the /tmp. That works fine for me.
For mongo v3.6.3+ (or 2019 versions)
rm /var/lib/mongodb/mongod.lock
service mongodb restart
I understand the question is with regards to Ubuntu.
But if you're getting the same error on a Mac and don't want $ sudo mongod running on a separate tab, you can do the following to fix the connection error, if you have Homebrew -
brew services start mongodb
Based on the answer from this thread - Cannot connect to mongodb errno:61 Connection refused
In my case bind_ip was not 127.0.0.1 in /etc/mongodb.conf file so change bind_ip to 127.0.0.1(it may be comma separated values so make sure 127.0.0.1 is one of them) Then restart your system to take effect.
Restart only to the those who are facing
$sudo service mongod restart
Failed to restart mongod.service: Unit mongod.service not found.
Follow this simple steps; (Works on MAC OS too)
Open terminal and run sudo mongod
Open a new terminal tab(Don't close step 1 tab) and run sudo mongo
That's all
is very simple, only delete a file /var/lib/mongodb/mongodb.lock. after only execute: mongo. finished
It is possible that the data directory for mongo specified in /etc/mongod.conf is not a valid path.
Try rechecking the path if it really exists sudo vi /etc/mongod.conf and check dbPath.
Just some thoughts on my case.
If you have changed the dbPath and logPath dirs to your custom values (say /data/mongodb/data, /data/mongodb/log), you must chown them to mongodb user, otherwise, the non-existent /data/db/ dir will be used.
sudo chown -R mongodb:mongodb /data/mongodb/
sudo service mongod restart
I have the same error with you, this is my case:
~# mongod
2018-07-15T05:27:08.265+0000 I JOURNAL [initandlisten] journal dir=/data/db/journal
2018-07-15T05:27:08.265+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2018-07-15T05:27:08.301+0000 I JOURNAL [durability] Durability thread started
2018-07-15T05:27:08.301+0000 I JOURNAL [journal writer] Journal writer thread started
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten] MongoDB starting : pid=26796 port=27017 dbpath=/data/db 64-bit host=ubuntu-s-2vcpu-4gb-sfo2-01
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten]
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten]
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten]
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten] db version v3.0.6
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten] git version: 1ef45a23a4c5e3480ac919b28afcba3c615488f2
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten] build info: Linux build6.ny.cbi.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten] allocator: tcmalloc
2018-07-15T05:27:08.302+0000 I CONTROL [initandlisten] options: {}
2018-07-15T05:27:08.308+0000 I NETWORK [initandlisten] waiting for connections on port 27017
I type mongod to start the server, and I type control + c to exit to shell
then I type mongo and I got
~# mongo
MongoDB shell version: 3.0.6
connecting to: test
2018-07-15T05:05:02.738+0000 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2018-07-15T05:05:02.739+0000 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
As you can see, my error info is same with you.
This is case mongod doesn't start with backend process, when I type control + c I quit mongod.
We can add --fork args to make the process daemon process.
# mongod --logpath /usr/local/mongodb/log.txt --fork
you have to set --logpath if you want to use --fork
then you will success to connect to mongo
I faced the same problem, so please check is there mongodb folder, firstly try to remove that folder
rm -rf /var/lib/mongodb/*
Now try to start mongo and if same problem then its mongodb lock file which prevent to start mongo, so please delete the mongo lock file
rm /var/lib/mongodb/mongod.lock
For forcefully rm -rf /var/lib/mongodb/mongod.lock
service mongodb restart if already in sudo mode
otherwise you need to use like sudo service mongod start
or you can start the server using fork method
mongod --fork --config /etc/mongod.conf
and for watching the same is it forked please check using the below command
ps aux | grep mongo
Mongo 3.*.* - OSX - 2017
From README
RUNNING
Change directory to mongodb-osx-x86_64-3.*.*/bin
To run a single server database:
$ mkdir /data/db
$ ./mongod
Go to new Terminal
$ # The mongo javascript shell connects to localhost and test database
$ # by default -Run the following command in new terminal
$ ./mongo
> help
I solved that simply by entering sudo mongo after mongod command.
I just removed mongo following the instructions here: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ And then I installed again following the instructions in the given link. Everything worked smoothly!
There are changes in mongod.conf file in the latest MongoDB v 3.6.5 +
Here is how I fixed this issue on mac os High Sierra v 10.12.3
Note: I assume that you have installed/upgrade MongoDB using homebrew
mongo --version
MongoDB shell version v3.6.5
git version: a20ecd3e3a174162052ff99913bc2ca9a839d618
OpenSSL version: OpenSSL 1.0.2o 27 Mar 2018
allocator: system modules: none build environment:
distarch: x86_64
target_arch: x86_64
find mongod.conf file
sudo find / -name mongod.conf`
/usr/local/etc/mongod.conf > first result .
open mongod.conf file
sudo vi /usr/local/etc/mongod.conf
edit in the file for remote access under net: section
port: 27017
bindIpAll: true
#bindIp: 127.0.0.1 // comment this out
restart mongodb
if you have installed using brew than
brew services stop mongodb
brew services start mongodb
otherwise, kill the process.
sudo kill -9 <procssID>
Issue was with the connection to the database, it could be due to several reasons.
For me it was low disk space on my server machine, and when mongo tries to connect it refuse because of low disk, check your server machine local storage with du -sh if you have low storage space, check your logs size and take step accordingly, issue may exist because of dbpath contradict in /etc/mongod.conf and server actually running dbpath with mongod
If you are facing such type of issue, please check my answer in the given link below.
https://stackoverflow.com/a/53057695/8247133
For those with Windows. I had the same problem on Windows.
Restarting Mongodb service solves this.
Following are the steps to restart on Windows:
i). Go To "Services" on Windows.
ii). Search for "MongoDB" in the list of services.
iii). Right click "start"/"restart" depending on your status.
iv). After the status turns to "running" check if issue is resolved by running "Mongo" or connecting your Mongo client.
For macOS many of the answers are already outdated according to official docs. Somehow the brew has changed and how we should install MongoDB, firstly uninstall it from your macOS (even though it might be not necessary) and then install it using these steps:
brew tap mongodb/brew
brew install mongodb-community#4.4
brew services start mongodb-community#4.4
Watch out for the 4.4 part, it'll change. If in the future it would break then refer to the official docs and install the version, which is suggested in the linked tutorial.

Resources