I have to write a perl script to connect to mongodb. But I am not able connect to DB instance in my machine it is giving me the following error:
2016-09-19T12:54:03.257+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-09-19T12:54:03.257+0530 E STORAGE [initandlisten] Failed to set up sockets
during startup.
2016-09-19T12:54:03.259+0530 I CONTROL [initandlisten] dbexit: rc: 48
I tried checking if any other process is running on that port number, but for that particular PID there is no process running in the task manager.
When I am using Robomongo it is showing authentication failed. I am new to MongoDB. Please help.
TIA.
Related
Can't Start mongoDB on Windows 7 SP1 Machine..
2017-08-24T11:46:10.280+0300 E NETWORK [initandlisten] listen(): bind() failed
An operation was attempted on something that is not a socket. for socket: 0.0.
0.0:27017
2017-08-24T11:46:10.281+0300 E NETWORK [initandlisten] Failed to set up sockets
during startup.
2017-08-24T11:46:10.281+0300 E STORAGE [initandlisten] Failed to set up listene
r: InternalError: Failed to set up sockets
Any help is appreciated.
If you can run the following command to check whether the port 27017 is accessible or open for connections.
netstat -a -n | find "27017"
This will let you know if the MongoDB port is available for connection.
Alternately, you could open Task Manager and close all the open mongod processes.
Hope this helps!
I'm working on this automatic drink dispenser and ran into an issue when I downloaded the Mongo 3.0.7 I tried to run it but I keep getting this error:
I got the idea from this website. http://yujiangtham.com/2014/05/30/build-your-very-own-drink-mixing-robot-part-2/
2016-02-02T15:56:42.585-0500 E NETWORK [initandlisten] listen():
bind() failed errno:48 Address already in use for socket:
0.0.0.0:27017
2016-02-02T15:56:42.585-0500 E NETWORK [initandlisten] addr already
in use 2016-02-02T15:56:42.593-0500 W - [initandlisten]
Detected unclean shutdown - /data/db/mongod.lock is not empty.
2016-02-02T15:56:42.593-0500 I STORAGE [initandlisten] exception in
initAndListen: 98 Unable to lock file: /data/db/mongod.lock errno:35
Resource temporarily unavailable. Is a mongod instance already
running?, terminating
2016-02-02T15:56:42.593-0500 I CONTROL [initandlisten] dbexit: rc:
100
I need help on how to run this. The website I'm using as a reference is
http://yujiangtham.com/2014/05/30/build-your-very-own-drink-mixing-robot-part-2/
It is stating that Mongo is already running. If you are certain it is not, then the lock file still exists from a previous unclean shutdown.
ps aux | grep mongo
if that returns nothing, it will mean the lock file still exists. looking at your error, the file is /data/db/mongod.lock
rm /data/db/mongod.lock
Should get rid of it so you'll be able to start the mongo service running again.
Try running pkill mongod to kill the process
This has been covered in other SO posts, but unfortunately those solutions are not working.
How does one restart/delete a mongod instance?
Entering
$ mongod
I get the following error:
2016-01-24T09:49:19.557-0500 I CONTROL [initandlisten] MongoDB starting : pid=43675 port=27017 dbpath=/data/db 64-bit host=NAME-MacBook-Pro.local
2016-01-24T09:49:19.558-0500 I CONTROL [initandlisten] db version v3.0.8
2016-01-24T09:49:19.558-0500 I CONTROL [initandlisten] git version: 83d8cc25e00e42856924d84e220fbe4a839e605d
2016-01-24T09:49:19.558-0500 I CONTROL [initandlisten] build info: Darwin NAME-MacBook-Pro.local 15.2.0 Darwin Kernel Version 15.2.0: Fri Nov 13 19:56:56 PST 2015; root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2016-01-24T09:49:19.558-0500 I CONTROL [initandlisten] allocator: system
2016-01-24T09:49:19.558-0500 I CONTROL [initandlisten] options: {}
2016-01-24T09:49:19.558-0500 E NETWORK [initandlisten] listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017
2016-01-24T09:49:19.558-0500 E NETWORK [initandlisten] addr already in use
2016-01-24T09:49:19.558-0500 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-01-24T09:49:19.558-0500 I CONTROL [initandlisten] dbexit: rc: 100
I explicitly gave myself permissions with
sudo chown -R <USERNAME> /data/db
This didn't work.
I tried to remove the directory entirely
sudo rm -rf /data/db
and recreate it
mkdir -p /data/db
but unfortunately this doesn't work.
I thought the solution would be to remove the file /data/db/mongod.lock but it doesn't exist:
rm /data/db/mongod.lock
Anything else I should try?
EDIT: After running with the different port using mongod --port 12345, when I use use admin and then db.shutdownServer(), I get the following error:
2016-01-24T10:32:25.039-0500 I NETWORK trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2016-01-24T10:32:25.039-0500 I NETWORK reconnect 127.0.0.1:27017 (127.0.0.1) ok
2016-01-24T10:32:25.040-0500 I NETWORK DBClientCursor::init call() failed
server should be down...
EDIT 2:
Restarting the machine does nothing. I've tried to access the default port with mongod --port 27017, and then
> use admin
> db.shutdownServer()
I get the output:
2016-01-25T12:05:32.163-0500 I NETWORK DBClientCursor::init call() failed
server should be down...
2016-01-25T12:05:32.166-0500 I NETWORK trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2016-01-25T12:05:32.166-0500 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2016-01-25T12:05:32.166-0500 I NETWORK reconnect 127.0.0.1:27017 (127.0.0.1) failed failed couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
In the log it say:
2016-01-24T09:49:19.558-0500 E NETWORK [initandlisten] listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017
2016-01-24T09:49:19.558-0500 E NETWORK [initandlisten] addr already in use
It means that the port is already in use either by another process or another mongo instance.
You should use another port for this instance.
Refer to this link
I am taking the mongodb university class and having problems getting mongod to work properly. I have been trying for hours to try to get it to work properly, but I keep getting the same error.
When I try to run mongod I am getting this error:
erics-mbp:~ emlandst$ mongod --dbpath data
2015-08-16T18:55:24.186-0400 E NETWORK [initandlisten] listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017
2015-08-16T18:55:24.186-0400 E NETWORK [initandlisten] addr already in use
2015-08-16T18:55:24.186-0400 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory data not found., terminating
2015-08-16T18:55:24.186-0400 I CONTROL [initandlisten] dbexit: rc: 100
If I am correct the server is set to run on port 27017 by default and for some reason it is being blocked. I tried the ps waux | grep mongo and then I killed the instance, but still i get the same error.
I am trying to just delete everything so I can start all over, but I have no idea how to do that. I'm sure it is simple I just don't have a lot of experience. Thank you
when I try to start my database, mongodb is logging the following messages:
2014-08-12T08:42:17.522-0300 [initandlisten] journal dir=/www/mongodb/data/journal
2014-08-12T08:42:17.523-0300 [initandlisten] recover : no journal files present, no recovery needed
2014-08-12T08:42:17.564-0300 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2014-08-12T08:42:17.564-0300 [initandlisten] ERROR: addr already in use
2014-08-12T08:42:17.567-0300 [initandlisten] now exiting
2014-08-12T08:42:17.567-0300 [initandlisten] dbexit:
2014-08-12T08:42:17.567-0300 [initandlisten] shutdown: going to close listening sockets...
And it wont start.
But then I run the next command nothing is returned:
sudo netstat -ltnp | grep 27017
The server was manually shutdown (db.shutdownServer()) and it is a part of a replica set.
I noticed that the mongod.lock is created in the process, but removing it doesnt solve the problem.
So i guess the error message isnt quite right.
I'm using MongoDB shell version: 2.6.1
Anyone knows what could be the problem?
I had same issue.
In my config file in bindIp I had 2 ports specified, and for some reason mongo tried to run both of them simultaneously.
Leave only one and make sure it is in etc/hosts.