TypeError: o.resolveSrv is not a function while connecting Atlas from Node

Unable to connect to MongoDB cluster from Node JS

I had a cluster with DB(abhidb) and Collection(abhicol) Created

From Node.JS am using the following code

let monofun = async function mongoop() {
const { MongoClient } = require('mongodb');
    const uri = "mongodb+srv://abhisse:*****@cluster0.qpdme.mongodb.net/abhidb?retryWrites=true&w=majority";
    const client = new MongoClient(uri);

    try {
        await client.connect();

    } catch (e) {
    } finally {
        await client.close();

And I am getting this error , how do I resolve this please help…


Looks like you are missing the package that resolve SRV DNS entries.

Hi @Sr_Software_Develope, and welcome to the forums!

The error message screenshot that you have provided seems to be from a browser console (front-end), although you provided Node.js snippet (back-end).

If you are still having an issue connecting to the MongoDB Atlas cluster, could you please clarify where the error is occurring at ?

Please also provide a minimal example code so that others could reproduce the code.

If you would like to see a working example of connecting to MongoDB Atlas using MongoDB Node.js driver please see mongodb-developer/get-started-nodejs.