Error Please help me in this

Code : const mongoose = require("mongoose");
mongoose.set('strictQuery', false);
mongoose.connect("mongodb://localhost:27017/newDataSet", { useNewUrlParser: true })
.then(() => {
    console.log("Connected to MongoDB!");
.catch((error) => {
    console.error("Error connecting to MongoDB: ", error);

Error connecting to MongoDB:  MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
    at Connection.openUri (e:\Web\Mongooes\node_modules\mongoose\lib\connection.js:825:32)
    at e:\Web\Mongooes\node_modules\mongoose\lib\index.js:411:10
    at e:\Web\Mongooes\node_modules\mongoose\lib\helpers\promiseOrCallback.js:41:5
    at new Promise (<anonymous>)
    at promiseOrCallback (e:\Web\Mongooes\node_modules\mongoose\lib\helpers\promiseOrCallback.js:40:10)
    at Mongoose._promiseOrCallback (e:\Web\Mongooes\node_modules\mongoose\lib\index.js:1285:10)
    at Mongoose.connect (e:\Web\Mongooes\node_modules\mongoose\lib\index.js:410:20)
    at Object.<anonymous> (e:\Web\Mongooes\source\app.js:3:10)
    at Module._compile (node:internal/modules/cjs/loader:1226:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1280:10) {
  reason: TopologyDescription {
    type: 'Unknown',
    servers: Map(1) { 'localhost:27017' => [ServerDescription] },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: null,
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  code: undefined

Please give me code of this.

Try with instead of localhost in your code
Please search our forum threads for IPv6 for more details

I have same error with without localhost. I don’t know how resolve this error.
This error like this javascript - Error establishing MongoDB connection on localhost - Stack Overflow
without resolve yet