Server restriction is not working

Hi
db.createUser(
{
user: “testAj”,
pwd: “test123”,
roles: [{role: “read”, db: “dbname”}],
authenticationRestrictions: [ {
clientSource: [“192.168.3.ip”],
serverAddress: [“198.168.3.ip”]
} ]
}
)

getting this error
“msg”:“Failed to acquire user because of unmet authentication restrictions”

Failed to acquire user because of unmet authentication restrictions",“attr”:{“user”:“testAj@admin”,“reason”:"Restriction

Hi @Aayushi_Mangal

As a part of code, if the serverAddress unavailable or user could not be connecting from the IPs specified in clientSource . Can you please check the serverAddress is valid and please share complete error log along with the bindIp specified in your deployment.

Thanks,
Darshan

Thanks Darshan, Does bindip mentioned 0.0.0.0 in config file can be the reason of this error?think I found the cause, router is listening to 127.0.0.1 and we are restricting to internal ip, we must add that ip also listening right?

I’m not sure if this is a must. But it has no point to set a remote IP restriction when you are only listening on loopback address.

Thanks @Kobe_W , yes we are only listening to localhost.