Mongodb authentication failed., code 18

The "authentication failed" error message is often the result of one of five conditions.

  • Password is missing after copying connection string from the Atlas web page.  This is a security precaution, so you should enter the password manually in the Hackolade connection window.
  • Username and password mismatch
  • No user account exists in a new Atlas project under Clusters: Security: MongoDB Users or in your instance
  • Not specifying any or the correct "Authentication Database", (aka authSource), usually "admin"
  • Selecting an incorrect "Authentication" method

We recommend that you double-check the username and password, make sure the MongoDB user exists, verify the correct authentication database and make sure the authentication mechanism is supported by your MongoDB database.

For further troubleshooting:

  • If you are using Atlas, please refer the instructions on the Atlas Connect.
  • You may find the Connect to MongoDB documentation a helpful resource.
  • Are you able to successfully connect to the server using the mongo shell? If not, this suggests a potential problem with your database credentials.  In that case, please contact your database administrator.  If you are able to connect via the mongo shell, please provide the relevant shell connection settings and a screenshot of the error in the Compass connection dialog.

Problem: When attempting to rehome to a new MongoDB, it fails to authenticate. Sniffer capture shows it is not using the admin DB in Mongo to authenticate, rather it is trying to auth against the DB where Hygieia will be storing its data.

Relevant log excerpt:

[{address=REDACTED:27021, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='REDACTED', source='REDACTED_DB_NAME', password=, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server REDACTED:27021. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed", 

… where REDACTED_DB_NAME is the name of the DB that Hygieia will store its data, should it be able to auth… which is the same DB I see in the sniffer caps it is trying to perform initial auth to, instead of admin.

I have connected to the same Mongo cluster with the same creds - though using the admin DB to auth, of course - and it works fine.

I did try changing some of the Spring Boot config relevant to this (e.g.: spring.data.mongodb.authentication-database=admin), but no joy.

Is there something I’m missing here, or is the code hardwired to assume that the user lives in Hygieia’s DB, instead of admin?

Symptom

We installed the Workflow-Accelerator, but we get the following error message after we started the server:

java, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server localhost:27017. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }}}] com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='signavio', source='admin', password=, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server localhost:27017. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }}}]]]>

Resolution

The system cannot connect to your MongoDB. Please check the following solutions:

  • Is the password for your MongoDB user in your "effektif-onpremise.properties" correct?
  • If you open the "effektif-onpremise.properties"with a Editor, please use another tool (e.g. Notepad++). Afterwards, check if the password is in the same line as the "effektif.mongodb.password"-parameter

INLINECustomer Support

redred#ffe6e6INTERNAL TROUBLESHOOTING

German translation:

Keywords

KBA , BPI-SIG-PG-ONP , SAP Signavio Process Governance OnPremise , How To

Product

SAP Signavio Process Governance all versions ; Workflow Accelerator by Signavio all versions

How do I enable authentication in MongoDB?

How to Enable Authentication in MongoDB.
Create an administrator in the admin database with a userAdminAnyDatabase role. ... .
Disconnect from the mongo shell ( Ctrl+D )..
Locate the following code in the mongod configuration file ( /etc/mongod. ... .
Change authorization disabled to enabled and save the file..

What does authentication failed mean?

If you receive this error message, that means that the username and/or password that you have entered is incorrect. The error message states “Authentication failed! Try again.” You may have locked your account after too many attempts and your account will need to be reset.

Why MongoDB compass is not connecting?

This error often occurs when: You provide no hostname or an invalid hostname to the Compass connect dialog. The destination server rejects a connection on an incorrect port. Your MongoDB cluster or server has been shutdown or the server hostname has changed.

What is the default username and password for MongoDB?

By default mongodb has no enabled access control, so there is no default user or password. To enable access control, use either the command line option --auth or security.