I’m doing the challenge Create and Save a Record of a Model related to the course on MongoDB and Mongoose and I’m blocked because the verification system doesn’t accept my solution.
I also read and followed the tutorial to set up a hosted database.
When I click on “I’ve completed this challenge” the verification system tells me that
// running tests
Creating and saving a db item should succeed (Test timed out)
// tests completed
In the vscode terminal on gitpod I read that
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you’re trying to access the database from an IP that isn’t whitelisted. Make sure your current IP address is on your Atlas cluster’s IP whitelist
It is some time ago since I used mongoDB, but for the problem you are suggesting it is likely that the problem might be a mismatch between what you have in the configuration of your mongoDB instance and what you are sending to.
If it is not recognising your localhost (which I think it is what you are using), it is because it is expecting an URL that it is not receiving as such.
Check your mongoDB instance for the expected configuration of the URL. Before connecting to your mongoDB, try to make a test using something like Postman or anything that allows you to verify the URL shape you are sending and the one mongoDB is expecting.
Pay also attention to the expected security level you are providing (http or https)
A less systematic approach would be to try different possible aliases for your localhost (eg. localhost:/, 127.0.0.0:, 0.0.0.0:, etc).
Can you also provide a copy of the whole error you got on your console? I have been checking other similar posts where a similar error message to yours was shown but the actual problem was found somewhere else.
For example: the same error message appeared to someone who actually used a non-recognised method (remove instead of deleteAll).