I am trying to connect and run mongodb in docker. But it is showing error.
$docker pull mongo $ docker run -it mongo sh -c 'exec mongo
"$MONGO_PORT_27017_TCP_ADD R:$MONGO_PORT_27017_TCP_PORT/PMSDB" '
MongoDB shell version v3.6.2 connecting to: mongodb://:/PMSDB
2018-01-30T10:31:34.696+0000 E QUERY [thread1] Error: Empty host
component parsing HostAndPort from ":" :
connect#src/mongo/shell/mongo.js:251:13 #(connect):1:6 exception:
connect failed
user2#system2 MINGW64 ~/sample $
How to resolve this
Related
I'm trying to launch mongo through my script after installing mongodb, but it throw an error but when I try "mongo" from my terminal it works perfectly.
Error when I run mongo from my script :
MongoDB shell version: 3.2.21
connecting to: test
2018-10-11T10:38:32.855+0200 W NETWORK [thread1] Failed to connect to
127.0.0.1:27017, in(checking socket for error after poll), reason:
errno:111 Connection refused
2018-10-11T10:38:32.877+0200 E QUERY [thread1] Error: couldn't
connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:229:14
#(connect):1:6
exception: connect failed
Here is a part of my script
apt-get install -y mongodb-org
systemctl enable mongod
systemctl start mongod
echo " " >> /etc/mongod.conf
echo "replication:" >> /etc/mongod.conf
echo " oplogSizeMB: 1" >> /etc/mongod.conf
echo " replSetName: rs0" >> /etc/mongod.conf
sed '24d' /etc/mongod.conf
systemctl restart mongod
export LC_ALL=C
mongo --eval "rs.initiate()"
But when i just run "mongo" command on my terminal it works :
# mongo
MongoDB shell version: 3.2.21
connecting to: test
rs0:OTHER>
what might be the problem, please?
try with the following line:
/bin/bash -c "mongo --eval \"rs.initiate()\""
I have been trying to install Mongodb but it keeps failing midway. When the download is complete, installation fails with a connection error:
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2018-08-17T12:26:33.340+0200 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-08-17T12:26:33.340+0200 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
What I've tried:
1. Changing the port:
mongo --port 4332
but it doesn't connect still:
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:4332/
2018-08-17T12:32:55.743+0200 W NETWORK [thread1] Failed to connect to 127.0.0.1:4332, in(checking socket for error after poll), reason: Connection refused
2018-08-17T12:32:55.743+0200 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:4332, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
Reinstalling the DB shows up as complete but I still can't start it. Check out the screenshot
Checking for any config files in /etc/mongo* or /var/lib/: there is none.
Note: There's no mongod service available too.
the installation seem to have worked, but the mongod was not started.
MongoDB need two element :
the "mongo" shell utility, who is used to connect to the database direcly
the "mongod" service, who is the true database programs.
to start the mongod, simply use a cmd and use the "mongod" command. this command may fail if :
the port is already used (default is 27017)
the dbpath directory was not created (default is /data/db)
Fedora repository do not install both at the same time.
the shell is in the repository under the "mongodb" name
the server is under the name "mongodb-server"
so to install both, you need to do
dnf install mongodb mongodb-server
and you can then start the mongod service with
sudo service mongod start
more information
I am running a mean app, but when I go to run 'mongo', I get the following error:
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
2018-07-25T02:15:24.329-0500 E QUERY [js] Error: couldn't connect to
server 127.0.0.1:27017, connection attempt failed: SocketException: Error
connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
I am sure I am missing something simple here.
mongo is the Mongo shell. It connects to the Mongo daemon, mongod, which isn't running - hence the error.
At the command-line: sudo mongod
Enter your password, and the daemon should start. Now, when you run mongo it should start up ok.
I have facing issues while running mongo commend after successful installation of mongoDB version 3.6.3.
I have run mongo commend and got the following error
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2018-03-14T18:57:02.928+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-03-14T18:57:02.929+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
Run into the same problem, my error was that I was this command:
sudo mongo service mongod start
Instead of this:
sudo service mongod start
Make sure you run the second one, hopefully that is your error source as well.
I've created this Dockerfile in order to create an image:
FROM mongo:2.6
MAINTAINER Living Digital Way
COPY ./init.ms .
RUN mongo < ./init.ms
init.ms is like:
use fdb;
db.col.insert({"name": "name1"...});
...
As you can see I'm trying to add some data to my mongo instance.
When I'm building this image I get this message from Docker:
Step 4 : RUN mongo < ./init.ms
04:34:47
04:34:47 ---> Running in 96dd54d94bc6
04:34:47
04:34:47 MongoDB shell version: 2.6.12
04:34:47
04:34:47 connecting to: test
04:34:47
04:34:47 2016-09-07T08:34:47.482+0000 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
04:34:47
04:34:47 2016-09-07T08:34:47.483+0000 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
04:34:47
04:34:47 [91mexception: connect failed
04:34:47 [0m
04:34:47 ERROR: Build step failed with exception
Any ideas?
You should start mongod at first.
FROM mongo:2.6
MAINTAINER Living Digital Way
COPY ./init.ms .
# assume you are in mongo bin directory
RUN mongod -f you-config-path/mongo.conf
RUN mongo < ./init.ms