# MongoParseError: URI malformed, cannot be parsed / Password contains unescaped characters

**Code:** `MongoParseError: Password contains unescaped characters` · **Category:** MongoDB · **Seen on:** MongoDB, Node.js

The connection string contains characters in the user or password that must be percent-encoded.

## Meaning

Characters `: / ? # [ ] @ %` in credentials must be URL-encoded (`@` → `%40`, `/` → `%2F`). Build the URI with `encodeURIComponent`. The same applies to database names with special characters. Atlas users with passwords generated using symbols hit this frequently.

## Common causes

- `@` or `/` inside the password
- Unencoded `#`, `?`, `%`
- Copy-pasted connection string with `<password>` placeholder left in
- Spaces in credentials
- Missing `mongodb://` prefix

## Quick fix

1. `encodeURIComponent(password)` when building the URI
2. Replace `<password>` placeholder with the real encoded password
3. Use the driver's options object (`auth: {username, password}`)

## Detailed fix by platform

### Node.js

1. `const uri = \`mongodb+srv://${encodeURIComponent(u)}:${encodeURIComponent(p)}@cluster0.abcde.mongodb.net/db\`;`

## How to diagnose

1. **Password** — Special chars encoded?
2. **Placeholder** — Replaced?
3. **Scheme** — Correct?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/mongodb/mongosh-connection-string-special-characters)
