I cannot run mongod in my ubuntu machine. I read some blogs and stackoverflow threads suggesting to change the ownership of the /var/lib/mongodb and /var/log/mongodb folders by,
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown -R mongodb:mongodb /var/log/mongodb
but I still cant run mongod and getting the following error message.
vinayak#vinayak-Lenovo-G500:~$ mongod
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] MongoDB starting : pid=3211 port=27017 dbpath=/data/db 64-bit host=vinayak-Lenovo-G500
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] db version v3.2.3
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] allocator: tcmalloc
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] modules: none
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] build environment:
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] distmod: ubuntu1404
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] distarch: x86_64
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] target_arch: x86_64
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] options: {}
2016-03-04T09:31:29.968+0530 E NETWORK [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2016-03-04T09:31:29.968+0530 E NETWORK [initandlisten] addr already in use
2016-03-04T09:31:29.968+0530 E STORAGE [initandlisten] Failed to set up sockets during startup.
2016-03-04T09:31:29.968+0530 I CONTROL [initandlisten] dbexit: rc: 48
vinayak#vinayak-Lenovo-G500:~$
..and I don't think so, my mongodb is corrupted as it is fresh install and I haven't tweaked anything in it.
Please suggest any solution. Thank you.
By your stack trace Error " Address already in use for socket: 0.0.0.0:27017"
You can try running on a different port
e.g
mongod --port 12345
Write following thing in the terminal and it would definitely work(it have worked for me in macbook).
sudo killall -15 mongod
Related
I know that there are other questions similar to this, but they do not have the same exact log and I have tried many supposed solutions that haven't worked. This is my log:
2018-05-16T00:31:32.193-0400 I CONTROL [initandlisten] MongoDB starting : pid=16976 port=27017 dbpath=/data/db 64-bit host=Edan
2018-05-16T00:31:32.194-0400 I CONTROL [initandlisten] db version v3.6.1
2018-05-16T00:31:32.194-0400 I CONTROL [initandlisten] git version: 025d4f4fe61efd1fb6f0005be20cb45a004093d1
2018-05-16T00:31:32.194-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2o 27 Mar 2018
2018-05-16T00:31:32.194-0400 I CONTROL [initandlisten] allocator: system
2018-05-16T00:31:32.194-0400 I CONTROL [initandlisten] modules: none
2018-05-16T00:31:32.194-0400 I CONTROL [initandlisten] build environment:
2018-05-16T00:31:32.194-0400 I CONTROL [initandlisten] distarch: x86_64
2018-05-16T00:31:32.194-0400 I CONTROL [initandlisten] target_arch: x86_64
2018-05-16T00:31:32.194-0400 I CONTROL [initandlisten] options: {}
2018-05-16T00:31:32.194-0400 I STORAGE [initandlisten] exception in initAndListen: DBPathInUse: Unable to lock the lock file: /data/db/mongod.lock (Resource temporarily unavailable). Another mongod instance is already running on the /data/db directory, terminating
2018-05-16T00:31:32.194-0400 I CONTROL [initandlisten] now exiting
2018-05-16T00:31:32.194-0400 I CONTROL [initandlisten] shutting down with code:100
I think that I closed my terminal window before shutting down the server, and now I can't get it to work. Any help would be greatly appreciated.
It is mentioned in the log that "Another mongod instance is already running" and you need to gracefully shut down it before starting the server again.
If it didn't work, forcefully kill the mongod process and remove the lock file.
If you are on unix environment,
Run ps -A | grep mongo
Copy the process id(s)
Run kill -9 [process id]
And then remove the mongo lock file
Run sudo rm /data/db/mongod.lock
Im trying to start mongodb it returns me this error, i already tried to repair mongo reinstall using brew uninstalling and installing again and nothing happens.
This problem occurred after Mac OS High Sierra Update.
Here's the error:
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] MongoDB starting : pid=11915 port=27017 dbpath=/data/db 64-bit host=Luizs-MacBook-Pro.local
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] db version v3.4.9
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2l 25 May 2017
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] allocator: system
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] modules: none
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] build environment:
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] distarch: x86_64
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] target_arch: x86_64
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] options: {}
2017-09-27T20:55:54.835-0300 E NETWORK [initandlisten] listen(): bind() failed No such file or directory for socket: /tmp/mongodb-27017.sock
2017-09-27T20:55:54.836-0300 E NETWORK [initandlisten] Failed to set up sockets during startup.
2017-09-27T20:55:54.836-0300 E STORAGE [initandlisten] Failed to set up listener: InternalError: Failed to set up sockets
2017-09-27T20:55:54.836-0300 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-09-27T20:55:54.836-0300 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-09-27T20:55:54.836-0300 I CONTROL [initandlisten] now exiting
2017-09-27T20:55:54.836-0300 I CONTROL [initandlisten] shutting down with code:48
What i already tried:
mongod --dbpath /data/db --repair
rm -rf /tmp/mongodb-27017.sock
rm -rf /data/db
Try :
1: sudo mongod --dbpath /data/db
Replace /data/db by your mongodb location same as :
sudo mongod --dbpath /var/lib/mongodb
2: Check Port Status
sudo netstat -tlnp | grep 27017
netstat -an |grep 27017
3: Kill ID
sudo killall mongod
sudo killall -15 mongod
sudo kill < Process ID >
When running:
mongod
I get:
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] MongoDB starting : pid=1160 port=27017 dbpath=/data/db 64-bit host=Interstellar
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] db version v3.4.4
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] git version: 888390515874a9debd1b6c5d36559ca86b44babd
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2k 26 Jan 2017
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] allocator: system
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] modules: none
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] build environment:
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] distarch: x86_64
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] target_arch: x86_64
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] options: {}
2017-04-30T11:19:56.235+0600 I STORAGE [initandlisten] exception in
initAndListen: 29 Data directory /data/db not found., terminating
2017-04-30T11:19:56.235+0600 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-04-30T11:19:56.235+0600 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] now exiting
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] shutting down with code:100
I'm having trouble with this, badly need help
The problem is that if you run "mongod" the default path is /usr/data. NEVERTHELESS macOS Catalina does not accept creating a writable folder there. So after long research, in both here, and reddit, I finally got my server (mongod as well as Mongo) up and running. Try the following these steps:
mkdir -p /System/Volumes/Data/data/db
sudo chown -Rv <your_user_name> /System/Volumes/Data/data/db
sudo mongod --dbpath /System/Volumes/Data/data/db
This may run mongod and start the server. Open another terminal tab, and type Mongo.
First step
brew services start mongodb/brew/mongodb-community#4.4
Second step
cd /Users
whoami
cd to your whoami directory
mkdir data
cd data
mkdir db
mongod --dbpath ~/data/db
Third step
mongo
The problem is that there is no /data/db directory. Please issue this command:
sudo mkdir -p /data/db
If you're not worried about opening up permissions too widely, but just want to ensure that mongodb has permissions to start, you can also issue these commands. They may fix any problems you have if the above command alone doesn't solve things.
cd /
sudo chmod -R 777 data
After I install mongodb via homebrew, I get the following message when I type mongod:
kamflamenco ~ $ mongod
2016-08-02T15:34:39.934-0700 I CONTROL [initandlisten] MongoDB starting : pid=4167 port=27017 dbpath=/data/db 64-bit host=Kenzos-MacBook-Pro.local
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] db version v3.2.8
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2h 3 May 2016
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] allocator: system
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] modules: none
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] build environment:
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] distarch: x86_64
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] target_arch: x86_64
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] options: {}
2016-08-02T15:34:39.936-0700 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-08-02T15:34:39.938-0700 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2016-08-02T15:34:39.938-0700 I CONTROL [initandlisten] dbexit: rc: 100
I am new to this and I've tried researching on the error. However, I have no luck, including typing
sudo chmod 777
The only time mongod works is if I type sudo in front of it
sudo mongod
But I do not feel this is correct...
remove the mongod.lock file:
sudo rm /data/db/mongod.lock
I have Windows 8.1 Enterprise 64 bit machine. I have installed mongodb msi for windows with SSL support. I created all the perquisites required for environment setup. Now using command prompt I navigated to the bin directory present into the mongodb installation folder and executed the following command:
mongod.exe --dbpath "c:\data"
And I see the following response:
C:\mongodb\bin>mongod.exe --dbpath "c:\data"
2016-05-27T17:09:43.362+0530 I CONTROL [initandlisten] MongoDB starting : pid=2
108 port=27017 dbpath=C:\data\db\ 64-bit host=TestServer
2016-05-27T17:09:43.363+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/W
indows Server 2008 R2
2016-05-27T17:09:43.364+0530 I CONTROL [initandlisten] db version v3.2.6
2016-05-27T17:09:43.364+0530 I CONTROL [initandlisten] git version: 05552b562c7
a0b3143a729aaa0838e558dc49b25
2016-05-27T17:09:43.364+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL
1.0.1p-fips 9 Jul 2015
2016-05-27T17:09:43.364+0530 I CONTROL [initandlisten] allocator: tcmalloc
2016-05-27T17:09:43.364+0530 I CONTROL [initandlisten] modules: none
2016-05-27T17:09:43.364+0530 I CONTROL [initandlisten] build environment:
2016-05-27T17:09:43.364+0530 I CONTROL [initandlisten] distmod: 2008plus-ss
l
2016-05-27T17:09:43.364+0530 I CONTROL [initandlisten] distarch: x86_64
2016-05-27T17:09:43.365+0530 I CONTROL [initandlisten] target_arch: x86_64
2016-05-27T17:09:43.365+0530 I CONTROL [initandlisten] options: {}
2016-05-27T17:09:43.365+0530 E NETWORK [initandlisten] listen(): bind() failed
errno:10048 Only one usage of each socket address (protocol/network address/port
) is normally permitted. for socket: 0.0.0.0:27017
2016-05-27T17:09:43.366+0530 E STORAGE [initandlisten] Failed to set up sockets
during startup.
2016-05-27T17:09:43.366+0530 I CONTROL [initandlisten] dbexit: rc: 48
Can anyone please help me to how to fix this issue.
run
netstat -a -n | find "27017"
and chek if port 27017 is already used
F:\data\bin> netstat -a -n | find "27017"
TCP 0.0.0.0:27017 0.0.0.0:0 LISTENING
or run taskmgr and find and kill all mongod processes