MongoDB Error 18: AuthenticationFailed

Wrong username/password or wrong `authSource` database in connection URI.

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.0.0
Identifier: MongoDB Error 18: AuthenticationFailed Platform: MongoDB

Interactive Diagnostic Checklist

Safe Diagnostic Command:
mongosh --eval "db.runCommand({ ping: 1 })"

Technical Explanation

Wrong username/password or wrong `authSource` database in connection URI. Verified technical resolution: Verify `?authSource=admin` and URL-encode special characters in the password.

Worked Examples

  • Diagnostic check: mongosh --eval "db.runCommand({ ping: 1 })"

Limitations & Assumptions

  • Confirm exact software version and execution layer before applying configuration changes in production.

Source References & Verification

Resource ID: err-mongo-auth-failed-18 · Independently verified: 2026-11-25

Related Resources