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 >
Related
I am developing in which I am using MongoDB as my database and I use the the following commands to install on the terminal on cloud 9.
$ sudo apt-get install -y mongodb-org
$ mkdir data
$ echo 'mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$#"' > mongod
$ chmod a+x mongod
$ ./mongod
This worked fine and I closed the terminal after I finished. Then I got back to it and I just typed: $ ./mongod in order to run the program but it's giving me the following error:
2017-12-24T07:02:40.787+0000 ** WARNING: --rest is specified without --httpinterface,
2017-12-24T07:02:40.787+0000 ** enabling http interface
warning: bind_ip of 0.0.0.0 is unnecessary; listens on all ips by default
2017-12-24T07:02:40.790+0000 [initandlisten] MongoDB starting : pid=15545 port=27017 dbpath=data 64-bit host=traorefly-real-5786569
2017-12-24T07:02:40.790+0000 [initandlisten] db version v2.6.12
2017-12-24T07:02:40.790+0000 [initandlisten] git version: d73c92b1c85703828b55c2916a5dd4ad46535f6a
2017-12-24T07:02:40.790+0000 [initandlisten] build info: Linux build5.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
2017-12-24T07:02:40.790+0000 [initandlisten] allocator: tcmalloc
2017-12-24T07:02:40.790+0000 [initandlisten] options: { net: { bindIp: "0.0.0.0", http: { RESTInterfaceEnabled: true, enabled: true } }, storage: { dbPath: "data", journal: { enabled: false } } }
2017-12-24T07:02:40.811+0000 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2017-12-24T07:02:40.811+0000 [initandlisten] ERROR: addr already in use
2017-12-24T07:02:40.811+0000 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017
2017-12-24T07:02:40.811+0000 [initandlisten] ERROR: addr already in use
2017-12-24T07:02:40.814+0000 [initandlisten] now exiting
2017-12-24T07:02:40.814+0000 [initandlisten] dbexit:
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: going to close listening sockets...
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: going to flush diaglog...
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: going to close sockets...
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: waiting for fs preallocator...
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: closing all files...
2017-12-24T07:02:40.814+0000 [initandlisten] closeAllFiles() finished
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: removing fs lock...
2017-12-24T07:02:40.814+0000 [initandlisten] dbexit: really exiting now
Some people said to delete *mongod.lock that's created inside the data file and then use --repair an then run it but it still doesn't work.
You're starting an instance of mongod while one is already running in the background. You could use ps -A to look for the mongod process, and subsequently use kill <process id> to kill that instance.
If the port is blocked by any other process, you can find that out with: lsof -i :27017
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mongod 30284 ubuntu 5u IPv4 447749095 0t0 TCP *:27017 (LISTEN)
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
I upgraded from debian 6 to debian 8. After that I upgraded MongoDB from ~2.5 to 3.2.9. They seemed to have changed the db path since I could not see any of my databases. I upgraded the dbpath. Stil I can't see any of my databases.
seprst#SESTOWS011:/data/db$ ls
graddays graddays.0 graddays.ns journal local local.0 local.ns mongod.lock mypdb mypdb.0 mypdb.ns
seprst#SESTOWS011:/data/db$ sudo service mongod stop
seprst#SESTOWS011:/data/db$ mongod --dbpath /data/db
2016-08-17T12:02:26.468+0200 I CONTROL [initandlisten] MongoDB starting : pid=22283 port=27017 dbpath=/data/db 64-bit host=SESTOWS011
2016-08-17T12:02:26.468+0200 I CONTROL [initandlisten] db version v3.2.9
2016-08-17T12:02:26.468+0200 I CONTROL [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c
2016-08-17T12:02:26.468+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1t 3 May 2016
2016-08-17T12:02:26.469+0200 I CONTROL [initandlisten] allocator: tcmalloc
2016-08-17T12:02:26.469+0200 I CONTROL [initandlisten] modules: none
2016-08-17T12:02:26.469+0200 I CONTROL [initandlisten] build environment:
2016-08-17T12:02:26.469+0200 I CONTROL [initandlisten] distmod: debian71
2016-08-17T12:02:26.469+0200 I CONTROL [initandlisten] distarch: x86_64
2016-08-17T12:02:26.469+0200 I CONTROL [initandlisten] target_arch: x86_64
2016-08-17T12:02:26.469+0200 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db" } }
2016-08-17T12:02:26.513+0200 I - [initandlisten] Detected data files in /data/db created by the 'mmapv1' storage engine, so setting the ac tive storage engine to 'mmapv1'.
2016-08-17T12:02:26.530+0200 I JOURNAL [initandlisten] journal dir=/data/db/journal
2016-08-17T12:02:26.545+0200 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2016-08-17T12:02:26.590+0200 I JOURNAL [initandlisten] warning couldn't write to / rename file /data/db/journal/prealloc.0: couldn't open file / data/db/journal/prealloc.0 for writing errno:9 Bad file descriptor
2016-08-17T12:02:26.590+0200 I STORAGE [initandlisten] exception in initAndListen: 13516 couldn't open file /data/db/journal/j._0 for writing er rno:9 Bad file descriptor, terminating
2016-08-17T12:02:26.590+0200 I CONTROL [initandlisten] now exiting
2016-08-17T12:02:26.590+0200 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2016-08-17T12:02:26.590+0200 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2016-08-17T12:02:26.590+0200 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2016-08-17T12:02:26.590+0200 I NETWORK [initandlisten] shutdown: going to close sockets...
2016-08-17T12:02:26.591+0200 I STORAGE [initandlisten] shutdown: waiting for fs preallocator...
2016-08-17T12:02:26.591+0200 I STORAGE [initandlisten] shutdown: final commit...
2016-08-17T12:02:26.591+0200 I STORAGE [initandlisten] shutdown: closing all files...
2016-08-17T12:02:26.591+0200 I STORAGE [initandlisten] closeAllFiles() finished
2016-08-17T12:02:26.591+0200 I CONTROL [initandlisten] dbexit: rc: 100
seprst#SESTOWS011:/data/db$ sudo service mongod start
seprst#SESTOWS011:/data/db$ mongo
MongoDB shell version: 3.2.9
connecting to: test
Server has startup warnings:
2016-08-17T12:02:40.540+0200 I CONTROL [initandlisten]
2016-08-17T12:02:40.540+0200 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-08-17T12:02:40.540+0200 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-08-17T12:02:40.540+0200 I CONTROL [initandlisten]
> show dbs
local 0.000GB
>
Any suggestions?
there is formatting issue with comment so posting as answer
ps -xa | grep mongod
open config file cat /etc/mongod.conf
for me it's dbPath: /var/lib/mongodb
you can check your settings.
to make changes permanent at your own risk
sudo service mongod stop
sudo ln -s /data/db/ /var/lib/mongodb
sudo chown mongodb:mongodb /data/db/
sudo service mongod start
//test if mongodb user can access new location:
sudo -u mongodb -s cd /data/db/
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 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