HI im working on a Windows 2019 VM on this machine I’ve installed MongoDB Community I opend the TCP Port 27017 and 27018 as well as the mongod.exe and mongos.exe but I’m still not able to connect to my MongoDB remotly.
I added a admin user this “mechanisms” : [
“SCRAM-SHA-1”,
“SCRAM-SHA-256”
]
not sure if this is important.
Im not 100% sure if i started MongoDB with Authentication but well…
When im on my VM I can only connect to the IP 127.0.0.1:27017 even with name and passwort but I cant connect to the external IP even tho im on the VM, remotly nothing worked so far.
Thanks that helped a lot, at least now I can connect as long as authentication is off, for some reason if I turn authentication on it cant find my user and autehntication failed even tho I use the same login from remote pc as I use in mongo on the VM.
You can create that first admin user with authentication enabled, as long as it is done via a connection on 127.0.0.1, this is the localhost exception.
Yes so first Installed the msi 4.4.4 from the MongoDB site and started it through the console with mongod, then I started mongo through console and entered
then I restarted mongod with mondog --auth --bind_ip_all
when im on the VM I can connect with my credentials with mongo -u root -p root
I tried to connect with Compass and with the Visual Studio Code Plugin from my remote pc and it doesnt work I only get the message in mongod in the console:
{“t”:{"$date":“2021-03-31T05:19:52.856-07:00”},“s”:“I”, “c”:“ACCESS”, “id”:xxxxx, “ctx”:“conn2”,“msg”:“Authentication failed”,“attr”:{“mechanism”:“SCRAM-SHA-256”,“principalName”:“root”,“authenticationDatabase”:“admin”,“client”:“xx.xxx.xxx.xxx:xxxx”,“result”:“UserNotFound: Could not find user “root” for db “admin””}}
If im on the VM and I try to connect to localhost or 127.0.0.1 with compas and the credentials it works fine.
Im pretty sure it cant be the Firewall, because If i set up noauth I can connect from my remote pc
Thanks for your answer I descriped my problem a little bit more detailed as you can see, maybe you know an answer. I dont know how this forum works if everybody get informed as soon as somebody answeres but thanks to you both so far i really appreciate it.
Yes it is kinda weird.
So basicly what I did wrong first was to create a user in my individual database with only reading rights and only after that i created a admin user on admin db.
Then I tried to deinstall everything, deleted everyfolder, registry everything and installed it new.
This time I created the admin user first in the admin database as mentioned before.
I am able to login from remote pc when --auth is off.
I am able to login on the VM if auth is off or on.
Im not able to connect when auth if on and I try to connect to the IP adress of the server, then mongod tells me the user doesnt exist. It doesnt matter if I try it on the VM or from my remote pc. Is it maybe because im Using mongo community?
I did a little more try and error maybe I did something in gernal wrong but after I did the following it worked:
start mongod --bind_ip_all
start mongo -host ip adress
use admin (no user here even tho i created some before aperently only on local host…)
create admin user as written above.
restart mongod --auth --bind_ip_all
connect from remote pc --> works
Thanks for your help guys propably i need to setup more now but im happy i got this far.
//but now if i connect with compas it tells me in mongod connection accepted but nothing is hown in compas on my remote pc. if i do it in visual studio code i at least get a message that it was successfully