Blog

AuthenticationFailed Error from MongoDB using ColdFusion 2021

November 8, 2021

I found that after changing the password for a MongoDB NoSQL DSN using ColdFusion Administrator you need to restart the ColdFusion Application service in Windows. Even changing to the correct password will cause a MongoDB authentication error:

Exception authenticating MongoCredential{mechanism=SCRAM-SHA-256, userName='{Your Username}', source='{Your Auth Source}', password=, mechanismProperties=} null
Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server XXXXXXXXXXXXX:27017. The full response is {"ok": 0.0, "errmsg": "Authentication failed.", "code": 18, "codeName": "AuthenticationFailed"}

This error may be logged in the MongoDB server log:

{"t":{"$date":"2021-11-08T14:39:07.067-06:00"},"s":"I",  "c":"ACCESS",   "id":20249,   "ctx":"conn122","msg":"Authentication failed","attr":{"mechanism":"SCRAM-SHA-256","speculative":false,"principalName":"{Your Username}","authenticationDatabase":"{Your Auth Source}","remote":"XXX.XXX.XXX.XXXX:51204","extraInfo":{},"error":"AuthenticationFailed: SCRAM authentication failed, storedKey mismatch"}}
Update 11/12/23 — Since writing this I’ve found it is sometimes necessary to delete the MongoDB DSN, restart ColdFusion, add the MongoDB DSN back, then restart the ColdFusion service again.

1 Comment

Brian Lang
Brian LangJuly 21, 2023 at 6:48:18 pm

Thank you. Your article solved the issue for me. Apparently creating a NEW NoSQL DSN falls into the "changing the password" trap and I had to restart the CF App Server service to be able to use the DSN in code. The verification button in the CF Admin worked so there was no indication from there that it wasn't working.

Leave Your Comment

Your email address will not be published. Required fields are marked *


about me

An information technology professional with twenty five years experience in systems administration, computer programming, requirements gathering, customer service, and technical support.