How to connect locally to mongodb from node.js

I have installed mongoDB on the same droplet as my node.js application in the root folder. But when i try to connect to my mongoDB database it is failing. It is telling me “Err too many redirects”. I am using the following line to try to connect with mongoose: mongoose.connect(“mongodb://username:password@127.0.0.1:27017?authSource=admin”, {useNewUrlParser: true });