18: AuthenticationFailed (error code 18)
MongoDBWhat does it mean?
Authentication failed. The supplied username, password or credentials are invalid; the user could not log in.
Why does it happen?
Wrong username/password, wrong authSource database, mismatched authentication mechanism (SCRAM-SHA-1/SCRAM-SHA-256), or the user is not defined in the specified database.
How to fix it
Verify the username and password. Specify the correct authSource in the connection string (the database where the user was created, usually admin): ...?authSource=admin. Check that the authentication mechanism is compatible with the server. Make sure the user was created in the correct database. URL-encode the password if it contains special characters.