Report this

What is the reason for this report?

How to connect locally to mongodb from node.js

Posted on April 24, 2019

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 });

In the UFW i have allowed income on my droplet IP and 27017.

Hope one of you can tell me what is wrong.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Have you started Mongo Server?

Can you connect it through command line like?

mongo -u username -p password --authenticationDatabase admin

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.