MongoDB and Mongoose - Install and Set Up Mongoose

I’m using the following connection string:


with the code

mongoose.connect(process.env.MONGO_URI).then(() => {
  console.log('Connected to database!')
}).catch(err => {

to connect to the mongoDB, but it is unable to connect. Could anyone please advise what to do here?

Hello and welcome to the forum!

Did you follow the tutorial linked in the challenge description?

You have saved your connection string in your .env file (or in your Secrets tab if you’re on Replit)? You have also inserted your username and password into your URI?

Also, as per the challenge instructions, your MongoDB connection should include the following:

mongoose.connect(<Your URI>, { useNewUrlParser: true, useUnifiedTopology: true });

…otherwise your URI will not be correctly parsed.

Do you have a link to your repl or project code please?

I have also edited your post to include a direct link to the challenge. It’s much easier to help you if you include that also.