I try to set up a mongodb database locally but would like to access it with host=ip address instead of host=localhost.
After setting up my users (admin, root + other users) through mongosh on 127.0.0.1:27017 (localhost), everything works fine when testing. It recognized the user i just created.
However, when trying to login to mongo via host=ip address, mongosh still logs in fine but cannot recognize the admin user.
I’m very confused about this behaviour, and this is preventing me login with a client with ip address (which i need because i want to use a docker container to then access my local mongo database).
I would appreciate some help here
Thanks!
PS: See attached screenshots of the 2 different behaviours.
It look like you are connecting to 2 different instances of mongod.
The one in 127.0.0.1 generates introduction messages that are different from the ones generated by the one at 192.168.1.119. In particular the one at 127.0.0.1 warns you that Access control is not enabled.
We need the output of the following commands. We need the output from both terminals, the one you use to connect to 127… and the one you use to connect to 192…
First i need to precise i run mongo on a windows machine. My ip addres 192.168.1.119 is the one i fixed on my network (i tried at least - wifi network).
I ran the commands i posted earlier on the same terminal back-to-back, while mongod was running in an other terminal.
The fact that the introductory message when login on localhost(127.0.0.1) mentionned that “Access control is not enabled” is indeed strange. In my mongod.conf, i have security authorization = enabled.
The other weird thing is that on localhost, when i request the list of db users, i can see my admin user in the admin database. However, when login on 192…, when i request the list of users and roles, i see no users (see attachments).
As i’m running my terminal on windows, the ss command is not working as it is a linux command, though i’m attaching the equivalent with netstat.
I am attaching a couple of screenshots that i hope can help:
mongod_conf.png → see binIp, port and authorization
mogosh_admin_user_locahost.png → details of admin user when login on localhost
mongosh_no_user_recognized_on_ip_192.png → no user found when login on ip=192.168.1.119
ps_grep_mongo.png (command ps -aef | grep [m]ongo, you requested)
routing_table_netstat_r.png
net_stat_o.txt (should be the ~equivalent to the “ss -tlnp” if i’m not mistaken?)
Just filtering by port 27017, this is what i see from my 2 ip addresses.
Any idea how to solve this issue?
Proto Local Address Foreign Address State PID
TCP 127.0.0.1:27017 kubernetes:50497 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:50498 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:50499 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:50500 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:50501 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:50502 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:50503 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:55095 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:55096 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:55097 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:55128 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:55129 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:55130 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:63075 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:63076 ESTABLISHED 5868
TCP 127.0.0.1:27017 kubernetes:63077 ESTABLISHED 5868
TCP 192.168.1.119:62175 host:27017 ESTABLISHED 23136
TCP 192.168.1.119:62176 host:27017 ESTABLISHED 23136
TCP 192.168.1.119:62177 host:27017 ESTABLISHED 23136
TCP 192.168.1.119:62178 host:27017 ESTABLISHED 23136