Solution skill
Atlas auth fails only for passwords with special characters
Complete solution
A password containing @, /, or : breaks URI parsing and looks like wrong credentials. URL-encode just the password. Not for different error messages.
TL;DR: A password containing @, /, or : breaks URI parsing and looks like wrong credentials. URL-encode just the password. Confirm Look at the password. Fix URL-encode only the password before substituting it into the string: p@ss/w:rd becomes p%40ss%2Fw%3Ard.
The error
the user and password are definitely right (you just created them), but auth fails with `bad auth : Authentication failed`. The password contains `@`, `/`, `:`, `?`, `#`, or `%`.The fix
Auth fails with special-character passwords
Symptom: the user and password are definitely right (you just created them), but auth fails with bad auth : Authentication failed. The password contains @, /, :, ?, #, or %.
Confirm
Look at the password. If it contains any URI-reserved character, the driver parses the connection string wrong: @ ends the user-info section early, / starts a new path segment, : splits user from password in the wrong place. The server then receives a mangled password.
Fix
URL-encode only the password before substituting it into the string:
const uri = template.replace('[password]', encodeURIComponent(password));p@ss/w:rd becomes p%40ss%2Fw%3Ard. Never encode the whole URI; that breaks the scheme and hosts.
Verify
Connect with the encoded string. Then, to stop this class of bug forever, generate future passwords from a URI-safe alphabet (letters and digits plus a few safe symbols like - and _).
When to use this
- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: Atlas auth fails only for passwords with special characters.
- You want the fastest verified fix before digging through logs.
When not to use this
- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.
Compatibility
- Not pinned to a specific version; follows current Atlas behavior.
Also seen as
bad auth : Authentication failed- `.
Confirm
Look at the password. If it contains any URI-reserved character, the driver parses the connection string wrong:`
Evidence
URI encoding requirements for connection string credentials per https://www.mongodb.com/docs/manual/reference/connection-string/; auth failure troubleshooting per https://www.mongodb.com/docs/atlas/troubleshoot-connection/, verified 2026-09-26.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_qqWCOMS_Ny9QdBCKPfWw9Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Atlas auth fails only for passwords with special characters <span>— Vectle</span></a>