querySrv EREFUSED _mongodb._tcp.cluster0.tpvpc.mongodb.net

mongodb+srv://sam:<password>@cluster0.tpvpc.mongodb.net/test
After changing the password and the ‘test’ name to my password and database, while connecting to my database from compass it throws this error.
Not just compass, also when am trying to connect from my application with its corresponding connection string, am having the same error.
The error which keeps on coming is :
querySrv EREFUSED _mongodb._tcp.cluster0.tpvpc.mongodb.net

Thanks A2A :slight_smile:

Is your IP address correctly whitelisted?

I faced a similar issue while using MongoDB on Windows. What worked for me simply using a different internet connection. Like on switching to mobile hotspot it worked. Maybe there are some ISP level related

1 Like

Hello,

I have been experience the same issue on my project but I managed to resolve by changing node version see below image.

Filename - Posts.js

const express = require("express");

const mongodb = require("mongodb");

const router = express.Router();

// Get Posts

router.get("/", async (req, res) => {

  try {

    const posts = await loadPostsCollection();

    res.send(await posts.find({}).toArray());

  } catch (e) {

    console.log(e);

  }

});

async function loadPostsCollection() {

  const client = await mongodb.MongoClient.connect(

    "mongodb://abc123:<password>@vue-expess-mongodb-shard-00-00.cc1pu.mongodb.net:27017,vue-expess-mongodb-shard-00-01.cc1pu.mongodb.net:27017,vue-expess-mongodb-shard-00-02.cc1pu.mongodb.net:27017/posts_db?ssl=true&replicaSet=atlas-zk87tt-shard-0&authSource=admin&retryWrites=true&w=majority",

    {

      useNewUrlParser: true,

      useUnifiedTopology: true,

    },

  );

  return client.db("posts_db").collection("posts");

}

module.exports = router;

Lemme know if this help!

Thanks

1 Like