DenoDDeno
Powered by
cxxC
Denoβ€’4y agoβ€’
15 replies
cxx

Error connecting to MongoDB Atlas

Hello, I'm trying to connect to MongoDB Atlas via
mongoose
mongoose
(
npm:mongoose
npm:mongoose
) but encountered the following error:
error: Uncaught MongoAPIError: Server record does not share hostname with parent URI
    at resolveSRVRecord (file:///home/farish/.cache/deno/npm/registry.npmjs.org/mongodb/4.14.0/lib/connection_string.js:63:19)
    at async file:///home/farish/.cache/deno/npm/registry.npmjs.org/mongodb/4.14.0/lib/mongo_client.js:123:31
error: Uncaught MongoAPIError: Server record does not share hostname with parent URI
    at resolveSRVRecord (file:///home/farish/.cache/deno/npm/registry.npmjs.org/mongodb/4.14.0/lib/connection_string.js:63:19)
    at async file:///home/farish/.cache/deno/npm/registry.npmjs.org/mongodb/4.14.0/lib/mongo_client.js:123:31

My code:
import mongoose from 'npm:mongoose';

await mongoose.connect(
    'mongodb+srv://user:pass@main.pj9zc0r.mongodb.net/?retryWrites=true&w=majority',
);
import mongoose from 'npm:mongoose';

await mongoose.connect(
    'mongodb+srv://user:pass@main.pj9zc0r.mongodb.net/?retryWrites=true&w=majority',
);
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

MongoDB connection error on Deno Deploy
tas13Ttas13 / help
3y ago
Error connecting to mongoose when using deno cli
CesarCCesar / help
3y ago