Unable to start MongoDB. ERROR: addr already in use - mongodb

I tried running MongoDB in local server with mongod command and it failed to run. The error:
mongod --help for help and startup options
Sat Jan 31 13:07:16.392 [initandlisten] MongoDB starting : pid=5127 port=27017 dbpath=/data/db/ 64-bit host=leandrotk
Sat Jan 31 13:07:16.392 [initandlisten] db version v2.4.9
Sat Jan 31 13:07:16.392 [initandlisten] git version: nogitversion
Sat Jan 31 13:07:16.392 [initandlisten] build info: Linux orlo 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 BOOST_LIB_VERSION=1_54
Sat Jan 31 13:07:16.392 [initandlisten] allocator: tcmalloc
Sat Jan 31 13:07:16.392 [initandlisten] options: {}
Sat Jan 31 13:07:16.435 [initandlisten] journal dir=/data/db/journal
Sat Jan 31 13:07:16.435 [initandlisten] recover : no journal files present, no recovery needed
Sat Jan 31 13:07:16.513 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
Sat Jan 31 13:07:16.514 [initandlisten] ERROR: addr already in use
Sat Jan 31 13:07:16.514 [websvr] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017
Sat Jan 31 13:07:16.514 [initandlisten] now exiting
Sat Jan 31 13:07:16.514 [websvr] ERROR: addr already in use
Sat Jan 31 13:07:16.514 dbexit:
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: going to close listening sockets...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: going to flush diaglog...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: going to close sockets...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: waiting for fs preallocator...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: lock for final commit...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: final commit...
Sat Jan 31 13:07:16.599 [initandlisten] shutdown: closing all files...
Sat Jan 31 13:07:16.599 [initandlisten] closeAllFiles() finished
Sat Jan 31 13:07:16.599 [initandlisten] journalCleanup...
Sat Jan 31 13:07:16.599 [initandlisten] removeJournalFiles
Sat Jan 31 13:07:16.668 [initandlisten] shutdown: removing fs lock...
Sat Jan 31 13:07:16.668 dbexit: really exiting now

you already have a process running
killall mongod
should kill the other process, if you have another kind of process bound to that port you could find it with netstat | grep 27017

Try this:
sudo service mongodb stop
sudo mongod

some version is:
sudo service mongod stop
mongod: mongo damon

Related

Unable to run mongod server on CentOS

When i try to run my mongod server on CentOS the result of npm start is this error:
root#server[Taxi]# npm start
> vframework#0.0.1 start /home/user/public_html/Taxi
> node server
/home/user/public_html/Taxi/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:72
const MongoParseError = function(message) {
^^^^^
the version of mongod is 2.4.14 and when i run the #mongod -v command i got this error
root#server [Taxi]# mongod -v
Fri Mar 30 19:07:42.038 BackgroundJob starting: DataFileSync
Fri Mar 30 19:07:42.038 versionArrayTest passed
Fri Mar 30 19:07:42.069 shardKeyTest passed
Fri Mar 30 19:07:42.069 isInRangeTest passed
Fri Mar 30 19:07:42.069 shardObjTest passed
Fri Mar 30 19:07:42.096 [initandlisten] MongoDB starting : pid=24586 port=27017 dbpath=/data/db/ 64-bit host=server
Fri Mar 30 19:07:42.096 [initandlisten] db version v2.4.14
Fri Mar 30 19:07:42.096 [initandlisten] git version: nogitversion
Fri Mar 30 19:07:42.096 [initandlisten] build info: Linux buildvm-11.phx2.fedoraproject.org 4.7.2-201.fc24.x86_64 #1 SMP Fri Aug 26 15:58:40 UTC 2016 x86_64 BOOST_LIB_VERSION=1_41
Fri Mar 30 19:07:42.096 [initandlisten] allocator: tcmalloc
Fri Mar 30 19:07:42.096 [initandlisten] options: { verbose: true }
Fri Mar 30 19:07:42.138 [initandlisten] User Assertion: 10310:Unable to lock file: /data/db/mongod.lock. Is a mongod instance already running?
Fri Mar 30 19:07:42.176 [initandlisten] exception in initAndListen: 10310 Unable to lock file: /data/db/mongod.lock. Is a mongod instance already running?, terminating
Fri Mar 30 19:07:42.177 dbexit:
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: going to close listening sockets...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: going to flush diaglog...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: going to close sockets...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: waiting for fs preallocator...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: lock for final commit...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: final commit...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: closing all files...
Fri Mar 30 19:07:42.179 [initandlisten] closeAllFiles() finished
Fri Mar 30 19:07:42.179 dbexit: really exiting now
i added a mongod.config file to path /etc/ fo specify the server adress and this is it's content
root#server [etc]# cat mongod.conf
logpath=/var/log/mongo/mongod.log
port=27027
bind_ip=0.0.0.0
dbpath=/var/lib/mongo
replSetName: rs0

mongod doesn't start even on start of the system

when I run sudo mongod on my ubuntu 14.04 it gives below error
mongod --help for help and startup options
Tue Mar 7 09:42:15.992 [initandlisten] MongoDB starting : pid=2870 port=27017 dbpath=/data/db/ 64-bit host=keshav-mohta
Tue Mar 7 09:42:15.992 [initandlisten] db version v2.4.9
Tue Mar 7 09:42:15.992 [initandlisten] git version: nogitversion
Tue Mar 7 09:42:15.992 [initandlisten] build info: Linux orlo 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 BOOST_LIB_VERSION=1_54
Tue Mar 7 09:42:15.992 [initandlisten] allocator: tcmalloc
Tue Mar 7 09:42:15.992 [initandlisten] options: {}
Tue Mar 7 09:42:16.431 [initandlisten] journal dir=/data/db/journal
Tue Mar 7 09:42:16.435 [initandlisten] recover : no journal files present, no recovery needed
Tue Mar 7 09:42:17.587 [websvr] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017
Tue Mar 7 09:42:17.587 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
Tue Mar 7 09:42:17.587 [websvr] ERROR: addr already in use
Tue Mar 7 09:42:17.587 [initandlisten] ERROR: addr already in use
Tue Mar 7 09:42:17.587 [initandlisten] now exiting
Tue Mar 7 09:42:17.587 dbexit:
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: going to close listening sockets...
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: going to flush diaglog...
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: going to close sockets...
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: waiting for fs preallocator...
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: lock for final commit...
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: final commit...
Tue Mar 7 09:42:17.760 [initandlisten] shutdown: closing all files...
Tue Mar 7 09:42:17.760 [initandlisten] closeAllFiles() finished
Tue Mar 7 09:42:17.760 [initandlisten] journalCleanup...
Tue Mar 7 09:42:17.760 [initandlisten] removeJournalFiles
Tue Mar 7 09:42:17.969 [initandlisten] shutdown: removing fs lock...
Tue Mar 7 09:42:17.969 dbexit: really exiting now
I know the solution to kill the process (sudo killall mongod) and then run the command again but my question is :
WHY it say addr already in use when I just start the system?
Is there any way so that I do not require to run 2 command on every morning to start mongod service.
UPDATE
my guess is that mongo service start on startup as I checked with
sudo initctl list | grep mongo
which output
mongodb start/running, process 1190
now I execute below command to stop mongodb on startup
sudo update-rc.d -f mongodb remove
which output
Removing any system startup links for /etc/init.d/mongodb ...
BUt it still display the mongodb in the list when check with sudo initctl list. even I start the system again to verify?
Step 1: Sometimes starting the services in completely new terminal ctrl + alt + T works.
Step 2: Use netstat to detect the port is running or not
netstat -anp | grep mongodPortHere
If it is running then use ps aux | grep "mongod" | less for processId and use kill -9 processId

MongoDb Bind_ip error: bind() failed errno:10049

My MongoDb Config file Content Is as below:
port=22000
bind_ip=127.0.0.1,192.168.1.121
auth=true
dbpath=D:\Data_For_Mongo
I am running my mongod instance using following command:
mongod -f "D:\mongoConfig.conf"
It Gives Me following Error:
ERROR: listen(): bind() failed errno:10049 The requested address is not valid in its context. for socket: 192.168.1.121:22000
The Whole Stack trace is As Below:
Fri Apr 11 09:24:18.600 [initandlisten] MongoDB starting : pid=3780 port=22000 dbpath=D:\Data_For_Mongo 64-bit host=SLK055
Fri Apr 11 09:24:18.600 [initandlisten] db version v2.4.6
Fri Apr 11 09:24:18.600 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673
Fri Apr 11 09:24:18.600 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49
Fri Apr 11 09:24:18.615 [initandlisten] allocator: system
Fri Apr 11 09:24:18.615 [initandlisten] options: { auth: "true", bind_ip: "192.168.1.80,192.168.1.121", config: "D:\mongoConfig.conf", dbpath: "D:\Data_For_Mongo", port: 22000 }
Fri Apr 11 09:24:18.647 [initandlisten] journal dir=D:\Data_For_Mongo\journal
Fri Apr 11 09:24:18.647 [initandlisten] recover : no journal files present, no recovery needed
Fri Apr 11 09:24:18.709 [initandlisten] ERROR: listen(): bind() failed errno:10049 The requested address is not valid in its context. for socket: 192.168.1.121:22000
Fri Apr 11 09:24:18.709 [websvr] ERROR: listen(): bind() failed errno:10049 The requested address is not valid in its context. for socket: 192.168.1.121:23000
Fri Apr 11 09:24:18.709 [initandlisten] now exiting
Fri Apr 11 09:24:18.725 dbexit:
Fri Apr 11 09:24:18.725 [initandlisten] shutdown: going to close listening sockets...
Fri Apr 11 09:24:18.740 [initandlisten] closing listening socket: 528
Fri Apr 11 09:24:18.740 [initandlisten] closing listening socket: 552
Fri Apr 11 09:24:18.740 [initandlisten] shutdown: going to flush diaglog...
Fri Apr 11 09:24:18.756 [initandlisten] shutdown: going to close sockets...
Fri Apr 11 09:24:18.756 [initandlisten] shutdown: waiting for fs preallocator...
Fri Apr 11 09:24:18.772 [initandlisten] shutdown: lock for final commit...
Fri Apr 11 09:24:18.772 [initandlisten] shutdown: final commit...
Fri Apr 11 09:24:18.834 [initandlisten] shutdown: closing all files...
Fri Apr 11 09:24:18.834 [initandlisten] closeAllFiles() finished
Fri Apr 11 09:24:18.834 [initandlisten] journalCleanup...
Fri Apr 11 09:24:18.834 [initandlisten] removeJournalFiles
Fri Apr 11 09:24:18.850 [initandlisten] shutdown: removing fs lock...
Fri Apr 11 09:24:18.850 dbexit: really exiting now
Bind Multiple ips is important for me.
Can AnyOne Help Me To Solve This Error?
I Have searched about error but can't find any way to bind multiple ips in mongo.
Thats a Windows Socket error. This is normally due to the IP address you are trying to bind to not being the IP of your local machine. You should double check that your system actually has the IP of 192.168.1.121

mongod shell doesn't start, data/db doesn't exsist

When I start mongod trowed error. What is the problem?
root#cs12867:~# mongod
mongod --help for help and startup options
Sun Dec 22 15:37:44.081 [initandlisten] MongoDB starting : pid=18415 port=27017 dbpath=/data/db/ 64-bit host=cs12867
Sun Dec 22 15:37:44.081 [initandlisten] db version v2.4.6
Sun Dec 22 15:37:44.081 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673
Sun Dec 22 15:37:44.081 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Sun Dec 22 15:37:44.081 [initandlisten] allocator: tcmalloc
Sun Dec 22 15:37:44.081 [initandlisten] options: {}
Sun Dec 22 15:37:44.081 [initandlisten] exception in initAndListen: 10296
*********************************************************************
ERROR: dbpath (/data/db/) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Sun Dec 22 15:37:44.081 dbexit:
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close listening sockets...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to flush diaglog...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close sockets...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: waiting for fs preallocator...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: lock for final commit...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: final commit...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: closing all files...
Sun Dec 22 15:37:44.081 [initandlisten] closeAllFiles() finished
Sun Dec 22 15:37:44.081 dbexit: really exiting now
I set --dbpath:
root#cs12867:~# mongod --dbpath /var/lib/mongodb/data/db
Sun Dec 22 15:29:25.121 [initandlisten] MongoDB starting : pid=17739 port=27017 dbpath=/var/lib/mongodb/data/db 64-bit host=cs12867
Sun Dec 22 15:29:25.121 [initandlisten] db version v2.4.6
Sun Dec 22 15:29:25.121 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673
Sun Dec 22 15:29:25.121 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Sun Dec 22 15:29:25.121 [initandlisten] allocator: tcmalloc
Sun Dec 22 15:29:25.121 [initandlisten] options: { dbpath: "/var/lib/mongodb/data/db" }
Sun Dec 22 15:29:25.121 [initandlisten]
Sun Dec 22 15:29:25.121 [initandlisten] ** WARNING: Readahead for /var/lib/mongodb/data/db is set to 2048KB
Sun Dec 22 15:29:25.121 [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less
Sun Dec 22 15:29:25.121 [initandlisten] ** http://dochub.mongodb.org/core/readahead
Sun Dec 22 15:29:25.123 [initandlisten] journal dir=/var/lib/mongodb/data/db/journal
Sun Dec 22 15:29:25.123 [initandlisten] recover : no journal files present, no recovery needed
Sun Dec 22 15:29:25.134 [initandlisten] waiting for connections on port 27017
Sun Dec 22 15:29:25.134 [websvr] admin web console waiting for connections on port 28017
Sun Dec 22 15:29:26.179 [initandlisten] connection accepted from 127.0.0.1:37164 #1 (1 connection now open)
Sun Dec 22 15:29:26.179 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.ns, filling with zeroes...
Sun Dec 22 15:29:26.179 [FileAllocator] creating directory /var/lib/mongodb/data/db/_tmp
Sun Dec 22 15:29:26.181 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.ns, size: 16MB, took 0 secs
Sun Dec 22 15:29:26.181 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.0, filling with zeroes...
Sun Dec 22 15:29:26.181 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.0, size: 64MB, took 0 secs
Sun Dec 22 15:29:26.182 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.1, filling with zeroes...
Sun Dec 22 15:29:26.182 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.1, size: 128MB, took 0 secs
Sun Dec 22 15:29:26.184 [conn1] build index Tester.user { _id: 1 }
Sun Dec 22 15:29:26.184 [conn1] build index done. scanned 0 total records. 0 secs
Sun Dec 22 15:29:26.184 [conn1] end connection 127.0.0.1:37164 (0 connections now open)
Sun Dec 22 15:29:26.192 [initandlisten] connection accepted from 127.0.0.1:37165 #2 (1 connection now open)
Sun Dec 22 15:29:26.732 [initandlisten] connection accepted from 127.0.0.1:37166 #3 (2 connections now open)
Sun Dec 22 15:29:26.733 [conn3] end connection 127.0.0.1:37166 (1 connection now open)
Sun Dec 22 15:29:26.740 [initandlisten] connection accepted from 127.0.0.1:37167 #4 (2 connections now open)
Sun Dec 22 15:29:26.740 [conn4] end connection 127.0.0.1:37167 (1 connection now open)
Sun Dec 22 15:29:26.834 [initandlisten] connection accepted from 127.0.0.1:37168 #5 (2 connections now open)
Sun Dec 22 15:29:26.835 [conn5] end connection 127.0.0.1:37168 (1 connection now open)
Sun Dec 22 15:29:26.843 [initandlisten] connection accepted from 127.0.0.1:37169 #6 (2 connections now open)
Sun Dec 22 15:29:27.252 [initandlisten] connection accepted from 127.0.0.1:37170 #7 (3 connections now open)
Sun Dec 22 15:29:27.253 [conn7] end connection 127.0.0.1:37170 (2 connections now open)
Sun Dec 22 15:29:27.304 [initandlisten] connection accepted from 127.0.0.1:37171 #8 (3 connections now open)
Sun Dec 22 15:29:27.304 [conn8] end connection 127.0.0.1:37171 (2 connections now open)
Sun Dec 22 15:29:28.332 [initandlisten] connection accepted from 127.0.0.1:37173 #9 (3 connections now open)
Sun Dec 22 15:29:28.333 [conn9] end connection 127.0.0.1:37173 (2 connections now open)
Sun Dec 22 15:29:28.352 [initandlisten] connection accepted from 127.0.0.1:37174 #10 (3 connections now open)
Sun Dec 22 15:29:28.842 [conn10] end connection 127.0.0.1:37174 (2 connections now open)
Sun Dec 22 15:29:28.862 [initandlisten] connection accepted from 127.0.0.1:37176 #11 (3 connections now open)
Sun Dec 22 15:29:28.863 [conn11] end connection 127.0.0.1:37176 (2 connections now open)
Sun Dec 22 15:29:30.362 [initandlisten] connection accepted from 127.0.0.1:37178 #12 (3 connections now open)
Sun Dec 22 15:29:30.363 [initandlisten] connection accepted from 127.0.0.1:37179 #13 (4 connections now open)
Sun Dec 22 15:29:30.364 [conn13] end connection 127.0.0.1:37179 (3 connections now open)
Sun Dec 22 15:37:36.523 [signalProcessingThread] shutdown: closing all files...
Sun Dec 22 15:37:36.523 [signalProcessingThread] closeAllFiles() finished
Sun Dec 22 15:37:36.523 [signalProcessingThread] journalCleanup...
Sun Dec 22 15:37:36.523 [signalProcessingThread] removeJournalFiles
Sun Dec 22 15:37:36.525 [signalProcessingThread] shutdown: removing fs lock...
Sun Dec 22 15:37:36.525 dbexit: really exiting now
Then again:
root#cs12867:~# mongod
mongod --help for help and startup options
Sun Dec 22 15:37:44.081 [initandlisten] MongoDB starting : pid=18415 port=27017 dbpath=/data/db/ 64-bit host=cs12867
Sun Dec 22 15:37:44.081 [initandlisten] db version v2.4.6
Sun Dec 22 15:37:44.081 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673
Sun Dec 22 15:37:44.081 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Sun Dec 22 15:37:44.081 [initandlisten] allocator: tcmalloc
Sun Dec 22 15:37:44.081 [initandlisten] options: {}
Sun Dec 22 15:37:44.081 [initandlisten] exception in initAndListen: 10296
*********************************************************************
ERROR: dbpath (/data/db/) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Sun Dec 22 15:37:44.081 dbexit:
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close listening sockets...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to flush diaglog...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close sockets...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: waiting for fs preallocator...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: lock for final commit...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: final commit...
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: closing all files...
Sun Dec 22 15:37:44.081 [initandlisten] closeAllFiles() finished
Sun Dec 22 15:37:44.081 dbexit: really exiting now
The default db path for mongodb is /data/db/.
So when you run:
mongod
MongoDB checks if /data/db/ is present and if the user has access to it. In your case, there is no such directory and hence the error.
However you can override the default db path using the --dbpath argument of mongod( or use a config file).
mongod --dbpath /var/lib/mongodb/data/db
In this case instead of checking for /data/db/ mongoDB check for /var/lib/mongodb/data/db. In your case, you have the specified directory and you have access to it and hence it runs.
And doing this doesn't start the mongo shell. To start the shell, start mongod first as mentioned above and leave it running. Then in another terminal execute
mongo
This will start the mongo shell.
As I see from the problem that creating the data/db directory will fix your problem.
Create that and then add like this if you have directory path in c drive.
mongod --dbpath "c://data/db"
After setting the dbpath you should start the mongodb as service.
sudo service mongodb start
Another solution to that problem could be:
.
Delete the files inside of /data/journal/ or /data/db/journal/
.
Especially if your database stopped working after an unclean restart / crash. It seems that the journal files can get corrupted and block the mongo service from starting.
Remember to backup the files first just in case.
Following these posts:
https://stackoverflow.com/a/16323101
https://jira.mongodb.org/browse/SERVER-5380

Start mongo failed

I get an error when I try to start mongo using the "mongod" command (on Macintosh).
all output going to: /usr/local/var/log/mongodb/mongo.log
My logs :
***** SERVER RESTARTED *****
Tue Oct 29 13:15:48.783 [initandlisten] MongoDB starting : pid=859 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=MacBook-Pro-de-Anthony
Tue Oct 29 13:15:48.784 [initandlisten] db version v2.4.4
Tue Oct 29 13:15:48.784 [initandlisten] git version: 4ec1fb96702c9d4c57b1e06dd34eb73a16e407d2
Tue Oct 29 13:15:48.784 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Tue Oct 29 13:15:48.784 [initandlisten] allocator: system
Tue Oct 29 13:15:48.784 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log" }
Tue Oct 29 13:15:48.784 [initandlisten] journal dir=/usr/local/var/mongodb/journal
Tue Oct 29 13:15:48.784 [initandlisten] recover : no journal files present, no recovery needed
Tue Oct 29 13:15:48.801 [initandlisten] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 127.0.0.1:27017
Tue Oct 29 13:15:48.801 [websvr] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 127.0.0.1:28017
Tue Oct 29 13:15:48.801 [initandlisten] ERROR: addr already in use
Tue Oct 29 13:15:48.801 [websvr] ERROR: addr already in use
Tue Oct 29 13:15:48.801 [initandlisten] now exiting
Tue Oct 29 13:15:48.801 dbexit:
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: going to close listening sockets...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: going to flush diaglog...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: going to close sockets...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: waiting for fs preallocator...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: lock for final commit...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: final commit...
Tue Oct 29 13:15:48.802 [initandlisten] shutdown: closing all files...
Tue Oct 29 13:15:48.802 [initandlisten] closeAllFiles() finished
Tue Oct 29 13:15:48.802 [initandlisten] journalCleanup...
Tue Oct 29 13:15:48.802 [initandlisten] removeJournalFiles
Tue Oct 29 13:15:48.803 [initandlisten] shutdown: removing fs lock...
Tue Oct 29 13:15:48.803 dbexit: really exiting now
UPDATE:
When I execute the "mongo" command :
MacBook-Pro-de-Anthony:Sites anthonycluse$ mongo
MongoDB shell version: 2.4.4
connecting to: test
Server has startup warnings:
Tue Oct 29 11:43:15 [initandlisten]
Tue Oct 29 11:43:15 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
> show dbs;
anthonycluse (empty)
local (empty)
>
It means that the username is "test" no?
UPDATE 2 :
The "show users;" command :
MacBook-Pro-de-Anthony:Sites anthonycluse$ mongo
MongoDB shell version: 2.4.4
connecting to: test
Server has startup warnings:
Tue Oct 29 11:43:15 [initandlisten]
Tue Oct 29 11:43:15 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
> show users;
>
Is there another process listening on those ports? Try finding out with:
netstat -tulpen | grep 017 # 017 for both port 27017 and 28017
Kill that process if you're sure you don't need it. As answered below by Lix, there may already be a mongo process running.
The answer is right there in side the log file:
Tue Oct 29 13:15:48.801 [websvr] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 127.0.0.1:28017
Specifically this part: "Address already in use for socket: 127.0.0.1:28017"
It seems that there is already a mongo instance running on that default port 27017. It might not even be a mongo instance but some other application that is using that port.
As per the logs it is clear that there is another mongodb instance running on default, i believe you installed mongodb using rpm and started this service using service mongodb start. so when the server restarts by default it starts some of the services, using defaultconfiguration which will be avialble in /etc/mongod.config edit this file or stop the one which is running already so you can avoid the mongod default instamce and made ur version to up and running