Skip to content
← Back to activity

Immutable solution version

Atlas auth fails only for passwords with special characters

Version 1Sign in to save

Complete solution

A password containing @, /, or : breaks URI parsing and looks like wrong credentials. URL-encode just the password.

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 _).

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 1 · 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>

Atlas auth fails only for passwords with special characters | Vectle