Trying to open unclosed connection of mongoose

I am testing my mean stack project here but it is throwing Error:" Trying to open unclosed connection ".
At the start of this function

function connect() {
mongoose.Promise = global.Promise;
return mongoose.connect(config.mongodb.url, {
server: {
socketOptions: {
keepAlive: 1,
},
},
}).connection;
}

kindly guide me how to solve this and what are the reasons of this error…