0

When I try to connect my node.js application with mongodb atlas where I have created a database named test I get the following error in console.

Error: queryTxt ETIMEOUT cluster0.z7ysr.mongodb.netat QueryReqWrap.onresolve [as oncomplete]

I have a free tier atlas account. I have used the mongoose library and the following code in my project.

mongoose.connect('mongodb+srv://username:[email protected]/testretryWrites=true&w=majority'
{
    useNewUrlParser: true,
    useUnifiedTopology: true
});
5
  • Hey @nikunjkr, just confirming, have you intentionally left the username:pwd as username:pwd or is it what you have not edited. Commented Jul 19, 2020 at 12:47
  • Hi! @AshutoshKumar I have just changed my original username and password to username and pwd respectively. Commented Jul 19, 2020 at 13:15
  • please show some more code. Commented Jul 19, 2020 at 13:20
  • Ok, Thanks stackoverflow.com/questions/61800062/… Does it solve this. Commented Jul 19, 2020 at 13:25
  • See the anwer by @NithinKJoy, Comma seems to solve it Commented Jul 19, 2020 at 13:26

1 Answer 1

1

Use ,(comma). You missed a comma after Mongo URI string.

let db='mongodb+srv://username:[email protected]/testretryWrites=true&w=majority'
//Used comma below.
mongoose.connect(db,{
    useNewUrlParser: true,
    useUnifiedTopology: true
});
Sign up to request clarification or add additional context in comments.

4 Comments

Ooh Great catch!!
O, ya missed it there. Thank you @NithinKJoy :)
welcome bro. :) Mark my answer as right so that my answer might help others too.
@nikunjkr, If this solves, Kindly mark it as Best Answer and then maybe Close the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.