Cap 1: The Mongod Lab - Launching Mongod : Error connecting to localhost:27000

When I try this command in this LAB:

mongo admin --host localhost:27000 --eval ’
db.createUser({
user: “m103-admin”,
pwd: “m103-pass”,
roles: [
{role: “root”, db: “admin”}
]
})

I get always:
Error: couldn’t connect to server localhost.27000, connection attemp failed :Socket Exception: Error connecting to localhost:27000 :: caused by :: …

What can I do?

If I execute this (first part of the lab):

mongod --dbpath /data/db --port 27000 --bind_ip “127.0.0.1,192.168.103.100” --auth

I get no error…

THanks in advance,

XAvi

Looks like quote after --eval is the issue
Try to type instead of cut & paste
or alternatively you can create the user after connecting to mongo
mongo admin --host localhost:27000

MongoDB Enterprise > db
admin
MongoDB Enterprise >db.createUser({
user: “m103-admin”,
pwd: “m103-pass”,
roles: [
{role: “root”, db: “admin”}
]
})

The text after caused by might be usefull to determined what is causing the problem.

Hi, I can connect to :
mongo admin --host localhost:27017

but not to :

mongo admin --host localhost:27000

I Get : couldn’t connect to servder 127.0.0.1:27000, connection attemp failed: Socked Excepction, caused by : “cannot connect so target deny connection explicitely…” --> translated from spanish.

What can I do?

Thanks a lot !!!

Xavi

Missatge de Ramachandra Tummala via MongoDB University Discussion Forum mongodb_university@discoursemail.com del dia dv., 17 de maig 2019 a les 16:35:

You are able to connect to 27017 as it is default port
Anyone can connect
C:\Users\ramrt\M003\m103-vagrant-env>mongo admin --host localhost:27017
MongoDB shell version v4.0.5
connecting to: mongodb://localhost:27017/admin?gssapiServiceName=mongodb

db
admin
show dbs
admin 0.000GB
config 0.000GB
local 0.000GB

Is your mongod up and running on 27000?
If yes did you try to create the user the way i suggested without using --eval

Hi Ramachandra,

Now it’s working fine.

Thanks !!

XAvi

Missatge de Ramachandra Tummala via MongoDB University Discussion Forum mongodb_university@discoursemail.com del dia ds., 18 de maig 2019 a les 6:24: