Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 271

Error: querySrv EREFUSED _mongodb._tcp.cluster0.vzygb.mongodb.net while connecting to mongodb

$
0
0

I've tried everything using chatgpt and configuring it again. Creating a new project and then creating a cluster and then doing all the process again.But this error seems to be stuck there. what is the problem? is the problem from MongoDb atla, that I've not configured it properly or anything else?

const path = require("path");const express = require("express");const bodyParser = require("body-parser");const mongoose = require("mongoose");const errorController = require("./controllers/error");const User = require("./models/user");const app = express();app.set("view engine", "ejs");app.set("views", "views");const adminRoutes = require("./routes/admin");const shopRoutes = require("./routes/shop");const authRoutes = require("./routes/auth");app.use(bodyParser.urlencoded({ extended: false }));app.use(express.static(path.join(__dirname, "public")));app.use((req, res, next) => {  User.findById("66c82709c6db121f94dd0d57")    .then((user) => {      req.user = user;      next();    })    .catch((err) => console.log(err));});app.use("/admin", adminRoutes);app.use(shopRoutes);app.use(authRoutes);app.use(errorController.get404);mongoose  .connect("mongodb+srv://vishalaggarwal_:Vishalrockk1@cluster0.vzygb.mongodb.net/",    { useNewUrlParser: true, useUnifiedTopology: true }  )  .then((result) => {    User.findOne().then((user) => {      if (!user) {        const user = new User({          name: "Max",          email: "max@test.com",          cart: {            items: [],          },        });        user.save();      }    });    app.listen(3000);  })  .catch((err) => {    console.log(err);  });
// Error// Error: querySrv EREFUSED _mongodb._tcp.cluster0.vzygb.mongodb.net    at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/callback_resolver:45:19)  syscall: 'querySrv',  hostname: '_mongodb._tcp.cluster0.vzygb.mongodb.net'}

Viewing all articles
Browse latest Browse all 271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>