dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Home/Error Library/mongodb-authentication-failed-scram-user-not-found
MongoDB
MongoDB 6.0 - 8.0Identity & Security
4 min read
Authentication failed. / BadValue: SCRAM-SHA-1 and SCRAM-SHA-256 / UserNotFound

MongoDB Authentication Failure: Missing authSource=admin, Database Scope Misconfigurations & SCRAM Credentials

Resolving authentication rejections caused by missing authSource parameters in URIs, role scope mismatches, and SCRAM-SHA-256 enforcement.

Reviewed by:Senior Database Architect & SRE (dataiotech Labs)
Tested Versions: MongoDB 6.0 / 7.0 / 8.0

Operational Verification & Reliability Metadata

Last Technical Review: 2 Kasım 2026
Tested VersionsMongoDB 7.0.8, 8.0.1
Required PrivilegesuserAdminAnyDatabase on admin
Risk Assessment
MediumMismatched authSource or invalid auth mechanisms permanently lock out applications
Expected OutputSuccessful mongosh authentication with explicit authSource parameter
Rollback Procedure:Append ?authSource=admin parameter to URI
MongoDB Docs: Authentication & SCRAM
First 60 Seconds Emergency Protocol:

The error string is a symptom, not the root cause. Do not restart the server blindly. Run the diagnostic queries below to pinpoint the actual failure mode.

▸Symptom

Authentication fails despite correct password credentials:

plaintext
MongoServerError: Authentication failed. MongoSecurityException: UserNotFound: Could not find user "app_user" for db "prod"

▸What You See in Production

Application startup crashes with authentication rejections. Credentials work in shell but fail in drivers.


▸Root Cause Matrix

ProbabilityRoot CauseDescription
%70Missing `authSource=admin`User provisioned in admin DB, but driver searches target DB for credentials.
%20SCRAM Mechanism MismatchLegacy driver defaulting to SCRAM-SHA-1 against modern cluster.
%10Scope Authorization GapsUser lacks readWrite privileges in destination database.

▸EMERGENCY RUNBOOK (0-5 min)

bash
# 1. Connect specifying authentication database mongosh -u app_user -p --authenticationDatabase admin 10.0.0.5:27017/prod
javascript
// 2. Inspect user roles use admin; db.getUser("app_user");

▸PERMANENT BLUEPRINT

  1. 1Explicit `authSource`: Always mandate ?authSource=admin on connection strings.
  2. 2Enforce SCRAM-SHA-256: Align driver versions to support modern authentication protocols.

▸Verification

bash
mongosh -u app_user -p 'Password' --authenticationDatabase admin --eval "db.stats()" 10.0.0.5:27017/prod

Other Database Error Triage Playbooks

Other battle-tested diagnostic guides for high-severity database errors.

All Errors (82)