Could someone please clarify why I'm encountering MongooseErrors when trying to connect to my database using localhost:27017, with a buffering timeout after 10000ms? Strangely, this issue doesn't occur if I use 127.0.0.1:27017. Note that I do not have Atlas installed.
Here is the code snippet that triggers the error:
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost:27017/fruitsDB", {useNewUrlParser: true,});
const Cat = mongoose.model('Cat', { name: String });
const kitty = new Cat({ name: 'Zildjian' });
kitty.save().then(() => console.log('meow'));
The problem seems to disappear when I switch from using localhost to 127.0.0.1.