MongoDB Connection String Checker and Builder
Find what’s wrong with a MongoDB URI, from unencoded passwords to SRV ports, or build a correct one for Atlas or a local server.
How to use the connection string checker
- Paste your connection string, or a whole
MONGODB_URI=…line from your.envfile. - Read the list of problems. Red items stop the connection; amber items are worth fixing.
- Copy the corrected string and the ready-made Mongoose code from the right-hand side.
Switch to Build a string to create a new one from a form. Passwords with special characters are encoded for you.
Everything runs in your browser, so your password is never sent anywhere. Even so, if you have shared a production password in a chat, ticket or screenshot, change it in Atlas.
The mistakes this tool catches
| Problem | What you see | Fix |
|---|---|---|
Password contains @ : / ? # |
Authentication errors or “URI malformed” | Percent-encode it, for example @ becomes %40 |
Placeholder left in, such as <db_password> |
Authentication failed | Replace it, including the angle brackets |
Port number on mongodb+srv:// |
Error that SRV URIs cannot have a port | Remove :27017 |
Several hosts on mongodb+srv:// |
Parse error | Use one host, or switch to mongodb:// |
localhost on Node.js 17 or newer |
ECONNREFUSED ::1:27017 |
Use 127.0.0.1 |
| No database name | Data lands in a database called test |
Add /myapp before the ? |
| Misspelled options | Option silently ignored or rejected | Fix the spelling, such as retryWrites |
Anatomy of a connection string
mongodb+srv://appUser:s3cret%40pass@cluster0.abcde.mongodb.net/shop?retryWrites=true&w=majority
└─scheme──┘ └─user─┘ └─password──┘ └──────────host──────────┘ └db┘ └──────────options──────────┘
The mongodb+srv:// scheme looks up the cluster’s servers through DNS, which is why it takes one host name and no port. The plain mongodb:// scheme lists every host and port yourself.
Still getting ECONNREFUSED or a server selection timeout? Read the full fix guide for MongooseServerSelectionError.
Frequently asked questions
How do I put special characters in a MongoDB password?
Percent-encode them: @ is %40, : is %3A, / is %2F, # is %23 and % is %25. In code, use encodeURIComponent(password) when you build the string.
What is the difference between mongodb:// and mongodb+srv://?
mongodb+srv:// takes one host name and finds the cluster members through a DNS SRV record. It is what MongoDB Atlas gives you. mongodb:// lists hosts and ports directly and is common for local and self-hosted servers.
When do I need authSource=admin?
When your user was created in the admin database but your connection string names a different database. Atlas users don’t usually need it.
More free tools
-
JSON to Mongoose Schema Converter
Paste a JSON document and get a ready-to-use Mongoose schema and model, with nested schemas, ObjectId refs and timestamps.
-
JSON to Zod Schema Generator
Turn any JSON into a Zod schema plus its TypeScript type, ready to validate API responses and form data.
-
JSON to TypeScript Interface Generator
Generate clean TypeScript interfaces from JSON in one paste, including nested objects, arrays and optional fields.
-
SQL to MongoDB Query Converter
Convert SQL queries to MongoDB find(), aggregate(), updateMany() and more, for mongosh or Mongoose.
-
PAN, Aadhaar, GST and IFSC Validator
Check PAN, Aadhaar, GSTIN, IFSC, PIN code, mobile and UPI formats, with real checksum tests and copy-ready regex.
-
MongoDB ObjectId to Timestamp Converter
See when any MongoDB document was created from its _id, or turn a date into an ObjectId for fast range queries.
