Thank you @andres , it solved my problem.
It was because of mongodb before version 4 by default passwordDigestor equals to “client” and its not compatible with SCRAM-SHA-256
so it fails the authentication . When we set it to “server” the server receives undigested password from the client and digests the password and authentication succeed .
1 Like