I have encountered a problem when connecting to a MongoDB database using Mongoose. I am using node js and express.
here is the error:
Error: queryTxt ESERVFAIL businessregistration-npeym.mongodb.net
(node:66755) UnhandledPromiseRejectionWarning: Error: queryTxt ESERVFAIL businessregistration-npeym.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:206:19)
(node:66755) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error 
originated either by throwing inside of an async function without a catch block, or by rejecting 
a promise which was not handled with .catch(). To terminate the node process on unhandled 
promise rejection, use the CLI flag `--unhandled-rejections=strict` (see 
https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
I think the main error is this: 
Error: queryTxt ESERVFAIL businessregistration-npeym.mongodb.net
My code:
const express = require("express");
const app = express();
const Schema = require("./Schema");
const mongoose = require("mongoose");
const port = process.env.PORT || 4000;
mongoose.connect(
  "mongodb+srv://<username>:<password>@businessregistration-npeym.mongodb.net/test?retryWrites=true&w=majority",
  { useNewUrlParser: true, useUnifiedTopology: true }
);
mongoose.connection.on("connected", function () {
  console.info("Connected!\n\n");
});
mongoose.connection.on("error", function (err) {
  console.error(`ERROR!!! The error is: ${err}\n\n`); // error is consoled here
});
mongoose.connection.on("disconnected", function () {
  console.warn(
    "The connection has been lost. This is because it got disconnected.\n\n"
  );
});
app.listen(port, () => {
  console.log(`Listening on port ${port}!`);
});
I do not know why this is suddenly happening. If you could help, thanks!
 
    