Tuesday 26 November 2019

For the life of me, I can't figure out why I can't connect to MongoDB

I am using mongoose to connect to mongodb. I have this connection code (below) and I just keep getting the error of MongoTimeoutError: Server selection timed out afterconst connection_string = 'mongodb+srv://' + config.MONGO_USER + ':' + config.MONGO_PASSWORD + '@cluster0-5398r.mongodb.net/basic-contacts?retryWrites=true&w=majority' console.log("CONNECTION: " + connection_string); mongoose.connect(connection_string, { useNewUrlParser: true, useUnifiedTopology: true }).then(result => { console.log("RESULT: " + result); }).catch(err => { console.log("ERROR: " + err); }); I have a database called basic-contacts and a collection called contacts. I know my username and password are properly passed in and are correct.What is strange is i went to previous projects I made from tutorials and they are also failing in the same way.Please help

Submitted November 27, 2019 at 02:54AM by Srz2

No comments:

Post a Comment