MongoDB Cluster connection instructions very confusing

Not sure how to connect to my cluster. The instruction provided by freeCodeCamp.com and the instruction on MongoDB is very confusing please help Thanks!
Here is a screen shot:- First one is the instruction by freeCodeCamp.com
the Second one is by mongodb

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36.

Challenge: Install and Set Up Mongoose

Link to the challenge:

I think this link will help you by understand what you need to do: freeCodeCamp Challenge Guide: Install and Set Up Mongoose
If u still don’t get it i be happy to explain the parts u did’t get :3

1 Like

Hello there,

These instructions were recently updated. So, let us see if we can confirm any more recent changes.

@moT01 I know you were involved with the update. Does this appear to have changed once more?

1 Like

@Sky020 I thought the instructions are outdated . Thanks for the answer

@KittyKora Thank you for the link I will check it out.

This is how I’ve done it.

MongoDB Setup:

  1. Go to MongoDB Atlas and Create an Account
  2. Create a Free Shared Cluster, customizing the location and name if you wish
  3. Wait for the cluster to be created → Usually about 5 minutes
  4. Go to Database Access, create a new user with a password (copy and paste this somewhere) and give the user read/write previlages
  5. Go to Clisters, Click Collection, Click Add my Own Data, and Create a Database and Collection, note down the database name
  6. Go to Network Access, Add IP Address, and allow access from anywhere
  7. Go to Clusters, Connect, Choose ‘Connect with App’, Copy the URI and paste it somewhere
  8. Edit the URI, to replace the database name and password.
5 Likes

I had a problem connecting to the database because I had my MONGO_URI set inside the sample.env
What fixed the problem is to create a new file with the name .env and put the URI there.
Hope this helps anyone else :slight_smile:

4 Likes

Thank you! This sent me down the right path. It’s worth noting that you must create a new “.env” file as you said.
Repl.it will not let you rename the file “sample.env” to “.env”. :slight_smile:

1 Like

Thanks, helped me too. :grin:

Does anyone know how to make the “sample.env” file to work? I tried

process.sample.env.MONGO_URI

but it didn’t work.

Hello there,

You are not supposed to use the sample.env file. It is common practice to include sample.env files in GitHub repos, because it is bad practice to include .env files (especially if they contain things like database passwords).

So, a sample.env file is provided with the bare minimum, which you are expected to clone, and add your values to in a .env file.

If you have any more questions about this subject, or your own code, I recommend you open a new topic for it on the forum.

Hope this clarifies.

1 Like

A post was split to a new topic: MongoDB Connection Fails Test

A post was split to a new topic: .env Files and Glitch with MongoDB Project