MongoParseError: URI malformed, cannot be parsed

I just started setting up the vs code env for mflix demo. Followed instructions. Have cluster up and runing on Atlas and able to connect to it via Compass. Also, set up dotenv_win.env file, added secret key and URI. Confirmed URI works in Compass. Went through the whole README to make sure all steps are done properly. When I run a test using:
npm test -t db-connection: I get this error.
FAIL test/db-connection.test.js
● Test suite failed to run
TypeError: Cannot read property ‘close’ of undefined

I have read this forum and see others have been able to fix it but I have tried all remedies, no result.

When I run this command: run start - I get this error:
[nodemon] watching extensions: js,mjs,json
[nodemon] starting node ./index.js
MongoParseError: URI malformed, cannot be parsed

Again, I see other threads with similar errors but somehow they have resolved. For me, I am not able to resolve this. Here is my dotenv_win.env file: (I have masked the password below)


Any help please. Thx.


Aren’t you supposed to rename this file to something else?

Most of the time, a screenshot is better than cut-n-pasting output, as the context helps the diagnostic.

1 Like

Attached is a screenshot. I was supposed to remane the file from donenv_win to donenv_win.env. That’s what I have done. See the screen shot of VS code, project is open, files are visible, content of the env file are visible and output from start command is also visible.

Thx for looking into this.

No, I think it was simply renamed to .env, nothing before the dot.

OMG - NO WAY!!! - How could I read this so wrong. I am spent hours in this frustration.
It works now…

I don’t know how to thank you, but Thank You!

Extra note for the future.

Remember to run the command from the root directory.

node src/migrations/movie-last-updated-migration.js

Since that is where your .env file is.


it is not working for me
can someone share his .env file ?
did u change the mognoEnvironment file ?

so frustrating

Why not share you .env file ?

password to my atlas…

So just hide the userid and the password in the image that you post.

This issue has been fixed.

1 Like

Thank you!!It helped me