Mongoose error const err = new MongooseError(message); - buffering timed out

954 Views Asked by At

I am trying to use node.js with MongoDB using Mongoose, but damn I am stuck in the same error for last week, it keeps giving the same error:

enter image description here

const mongoose = require("mongoose");
mongoose.set('strictQuery', true);
mongoose.connect("mongodb://localhost:27017/newDB", { useNewUrlParser: true ,  useUnifiedTopology: true 
 });

console.log("Connected")


//SCHEMA

const DBSchema = new mongoose.Schema ({name : String,anything : String})


const DaB= mongoose.model("Working",DBSchema)


const db=new DaB({name:"user",anything:"Some text"})

db.save();

I have tried various ways to fix it ,but it isnt fixing

1

There are 1 best solutions below

0
On

Don't use localhost, use 127.0.0.1.(Source - @robertklep)