mongodb remote authentication failure Mongod v4

491 views
Skip to first unread message

Mohd Sufian

unread,
Nov 27, 2018, 2:54:11 AM11/27/18
to mongodb-user

I have recently installed mongodb on one of our windows 2016 server with below configuration and running mongod as

enter code here

mongod --config C:\mongo_db\config\mongo_db_configuration.conf --auth

--config file
net:
    # MongoDB server listening port
    #bindIp: 0.0.0.0,192.168.43.250
    port: 27017
    bindIpAll: true
storage:
    # Data store directory
    dbPath: "C:\\mongo_db\\db"
    mmapv1:
        # Reduce data files size and journal files size
        smallFiles: true
systemLog:
    # Write logs to log file
    destination: file
    path: "C:\\mongo_db\\logs\\mongodb.log"
security:
  authorization: enabled

We have created a root user in admin database

    enter code here
MongoDB Enterprise > db.runCommand({connectionStatus:1})
{
        "authInfo" : {
                "authenticatedUsers" : [
                        {
                                "user" : "root",
                                "db" : "admin"
                        }
                ],
                "authenticatedUserRoles" : [
                        {
                                "role" : "dbAdminAnyDatabase",
                                "db" : "admin"
                        },
                        {
                                "role" : "root",
                                "db" : "admin"
                        }
                ]
        },
        "ok" : 1
}

I am able to connect to the mongod instance locally (mongo --port 27017 -u "root" -p "12345" --authenticationDatabase admin) but getting error while connecting remotely.the server firewall is disabled.

"C:\Mongodb>mongo.exe 192.168.0.171:27017/admin -u root -p 12345
MongoDB shell version v4.0.4
connecting to: mongodb://192.168.0.171:27017/admin
Implicit session: session { "id" : UUID("c68e9dd5-6f7b-4356-bc3e-688a7e2b3e1d") }
MongoDB server version: 4.0.4
2018-11-26T23:50:47.534+0800 E QUERY    [js] Error: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1685:20
@(auth):6:1
@(auth):1:2
exception: login failed"  

Kevin Adistambha

unread,
Nov 30, 2018, 12:54:12 AM11/30/18
to mongodb-user

Hi,

The error login failed implies that the username/password combination for the authentication database (admin) is incorrect. The presence of this error means that there should be no network issues.

Could you confirm that you’re connecting to the correct server at 192.168.0.171? I noticed that you commented out the IP address 192.168.43.250 in your config file. Do you have multiple MongoDB servers running in your network environment?

Best regards,
Kevin

王无忌

unread,
Feb 16, 2020, 12:49:13 AM2/16/20
to mongodb-user
I have the same problem with him:local authentication can be successful but remote authentication failed,my mongo version is 4.2.2 , the mongodb has run 5 months and the maxsize datafile of the collection is 180GB(only one file is 180G),all the other factors is not changed,I guess it is related to the huge file size but I am not sure.please help me many thanks.

在 2018年11月30日星期五 UTC+8下午1:54:12,Kevin Adistambha写道:
Reply all
Reply to author
Forward
0 new messages