Tell us what’s happening:
Im trying to create a new document using mongoose from my VS code app and save it in the database but every time I check the collection on Atlas cloud I find nothing .
Start by making sure you have the correct connection string with the right user and password and make sure you have white-listed your IP (or just all IPs i.e. 0.0.0.0/0).
You should see:
Listening on port 3000
connected
In the console. Your code should work when posting using the form. I just tested it.
Before you even try to post anything it should say “connected”.
I’m almost positive it is because you are not connecting correctly. I have seen that error message before and it was because either the connection string was wrong or the IP wasn’t whitelisted.
Not sure why you aren’t connecting either. As I said, I clone the repo and tested your code and it works for me. I also get that exact same error message if I use the wrong name or password or remove the IP whitelist.
I would suggest you log out process.env.DB_URI and make sure you are getting the value and triple-check you have the correct name/password. If that doesn’t work I would check that you are not blocking the connection locally (firewall). If you use something like TCPView you should see a node process with connections.
Well, I just meant logging out the variable to make sure you were getting it correctly. But hardcoding the connection string works as well. On the Database Access tab did you try clicking the edit button and checking the password?
You won’t see a connection in TCPView because you are not connected. You would see a node.exe process with some connections.
Edit: I missed this. That would confirm it to be a local issue. Maybe your router is blocking it? With the same code working on Replit I don’t really know what else can cause it, except the connection being blocked somehow.
Yes I already chucked the password and confirmed by rewriting it again , and as I said the same code worked in Replit and I saw the result on mongo db Atlas
If you have MongoDB installed locally as well try the code with a local DB. If that works it must be the connection.
If it is not the connection directly being blocked it might be the DNS being blocked. You can try using another DNS provider to test this. And as I said, if you are behind a router it can have firewall settings as well.