"mongoose" should be connected to a database is not working

Tell us what’s happening:
I have tried nearly everything and looked at the hints and I can
t get the final test to pass. I’m wondering if it has to do with mongoDB Atlas database. I cloned from Github where my username is joetags but my username is different in MongoDb atlas. I have tried both usernames and neither work. I tried disabling my VPN in case that was the reason.

Your project link(s)

solution: https://boilerplate-mongomongoose.joetags.repl.co

Your browser information:

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

Challenge: Install and Set Up Mongoose

Link to the challenge:

Hello there,

A few things to note:

  1. The sample.env file does nothing in your app. It is merely there as a reference for other developers to get an idea of the environment variables they might need to use. Environment variables should be stored in a .env file - On Replit, this is done through the SECRETS :lock: tab.
  2. MongoDB, Replit, and the freeCodeCamp tests do not care about your usernames - they can be whatever you want.
  3. The console is your best friend - do you see any errors?

Hope this clarifies

unhandled promise rejection warning TypeError: cannot read property ‘split’ of null
at ParseSrvConnectionString
at ParseConnectionString
at Connection

Right. Did you fix this?

I am using the secrets tab. I have MONGO_URI as the key and the mongodb path string as the value.

I tried deleting the sample.env, so it would only reference the secrets .env.

Well, if you are still seeing the error in the console, then it is an issue with your URI, and the best thing to do would be to go back to your Atlas dashboard, and copy the connection string again.

Thank you for your help! I have figured it out. The URL string that mongodb gives is incorrect.


This is what I had copied.

The correct URL is: mongodb://:@ds.mlab.com:/

In the help section of this lesson it shows this correct path under problem explanation but then it also shows the path that mongodb has the user copy under Hint #2.

Now for the real question! Why does the one work and not the other? And how would I have figured this out without the correct path being in the hint section? Thank you again.

I cannot say.

My URI looks like this, and works as expected:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.