MongoDB and Mongoose - version in package.json

// running tests

mongoose is not connected

Try to change the password in MongoDB atlas and make it very simple

can you please tell me how to create a new user in the cloud.mongo? or change the password ?
im doing this because we believe that one of the characters I chose is not being accepted. also i dont really understand this challenge nor did i learn what the purpose of this was

how do I change the password for a user in the cloud.mongodb ?

this is the query i am running :
https://docs.atlas.mongodb.com/?searchProperty=current&query=change%20password

No luck.

To change the password, go to MongoDB and login.
Once you’re in, you’ll see the vertical navigation bar on the left and clusters details on the right.

Click on Security underneath the Cluster section.

You’ll see your mongoDB users.
Click on edit button located on the right, next to delete.

Right under the user name, you will have an edit password button

You don’t export the MONGO_URI, you require the .env package in the root level of your app and use the process.env.MONGO_URI to access the connection string after you have assigned it in your .env file: https://learn.freecodecamp.org/apis-and-microservices/basic-node-and-express/use-the--env-file

I changed the password to not include any special characters, but i am still not connecting to the database.

the challenge you referenced says nothing about requiring the .env in the root level of you app.

I think you are trying to tell me that I have to require() the env file in the app.js (if that is what you mean by root level of my app)… although im not sure what your trying to say.

here is the way the code looks now but its still not connecting to the database, what do I have to do to fix it?

I was just giving you the true process you’d use to connect to your db, however in this case glitch takes care of your env file, If you correctly set the connection string in the .env file of your glitch app then you can just use process.env.MONGO_URI to connect to your db, again look at that lesson I linked above on how to correctly set your env variables.

Right now you have hardcoded your connection string, which you shouldn’t do, also your connection string is wrong, your app passes for me with a working connection string,
see here how to correctly connect to the new mongoDB atlas:

I was just giving you the true process you’d use to connect to your db, however in this case glitch takes care of your env file,

I read what you say but I dont understand this because I have no point of reference to know.

If you correctly set the connection string in the .env file of your glitch app then you can just use process.env.MONGO_URI to connect to your db, again look at that lesson I linked above on how to correctly set your env variables.

I read it a few times. I didnt see any new information that I did not already read or any new techniques that I did not attempt to utilize to get it to connect. I passed the challenges in that section, the challenge you referenced was easy to pass.

Right now you have hardcoded your connection string, which you shouldn’t do,

I think you mean that for security reasons ? well i tried doing the below as well but it doesnt work either :

mongoose.connect(process.env.MONGO_URI);

also your connection string is wrong, your app passes for me with a working connection string,

Why is the connection string wrong? I tried to connect using the second option ‘get a connection string and view driver examples’

see here how to correctly connect to the new mongoDB atlas:

MongoDB and Mongoose - Install and Set Up Mongoose Data
[/quote]

Is the below protocol incorrect ? Please advise:
https://github.com/freeCodeCamp/freeCodeCamp/blob/3218579479fa414f67915c663005548e252ccd8e/client/src/pages/learn/apis-and-microservices/mongodb-and-mongoose/index.md

when you develop locally, any information that you want to keep secret is attached to the process.env global Node object once you require the dotenv package in the root level of your app and set your secret strings appropriately, however with glitch, it automatically requires the package for your and all you have to do is set your secret (in this case mongoDB Atlas connection string) correctly in the .env file provided with all new glitch apps.

Yes, do not expose your connection string publicly, which is what you were doing.

Can’t say because there could be a number of things you did wrong when you set up the db, what I can say is that using the app you linked to earlier, I can pass the challenge using my own valid connection string, which tells me that something is wrong with your connection string and not anything else in your glitch app.

Actually, this one is more up to date: https://github.com/Dereje1/freeCodeCamp/blob/6639166396a485284a28f13460a8203d184d7825/client/src/pages/learn/apis-and-microservices/mongodb-and-mongoose/index.md

Follow it carefully and you should have no problems creating a valid connection string. This set of instructions should be integrated into the current production site within the next few weeks.

Yes I tried to follow all those steps, what is the difference between those instructions and the one I referenced, I could not get it to connect.

Here is my string:

mongoose.connect('mongodb+srv://dbuser:test@cluster0-6klo8.mongodb.net/test?retryWrites=true' ,{useNewUrlParser: true});

here is the example referenced in the last document you referenced:

mongodb+srv://<user>:<password>@<cluster#-dbname>.mongodb.net/test?retryWrites=true

once it connects I can put it in the env and reference it as you described using process.env.MONGO_URI ,
It should still connect even if im hard coding it yes?
I dont know whats wrong with the string because I copied the string generated by following your instructions and replaced user and password as per instructions. should I remove the second argument ?(usenewurlparser)

Is there anything else I can try?

When I click on connect a cluster it gives me three options I choose the middle one with the string. I copied and pasted this into the env file, not working. I hardcoded it, still not working. changed the password, added a new user, tried from different IP locations.

he has all the permissions

Make sure the user you made in MLab is not read-only. We can provide you more help if you put the link to your project.

This string passes for me,
first , make sure you are pasting in the LIVE glitch page link and not the editor link into the challenge

If the above doesn’t work, delete your glitch file, logout and log back in and start with a fresh template

We fixed it, but we are not sure if it was related to whitelisting the IP adresss, if its caching the whitelisted adress, or it could be related to the version of node that was installed.

But we believe it was the whitelisting issue. But we have not yet confirmed the reason why. Thank you for all your help and patience.

If you did not allow ’ ALLOW ACCESS FROM ANYWHERE in your first attempts, as per the instructions, that was the problem

hmmm… i’ll do some testing

@camperextraordinaire, I could not really duplicate what you said, the thing is, instead of first checking if the test is passing after you revert your ip address to not include all ip addresses, what you should do is check your glitch log after the reversion, and in order to do that, you have to change a minor thing in your glitch app for the app to reload (that is how glitch works with auto-save, kinda like codepen), once you reload your app, you should not be able to successfully connect to the db with just your local ip address white-listed, and should see an error message in your glitch log, this makes sense since your glitch app is not running locally but on it’s own server with it’s own ip. If you do not reload the app after the reversion however the tests will pass.

on a good note, the new instructions are now integrated in the production site, thanks for your help in getting this through.