MongoParseError

    MongoParseError: URI malformed, cannot be parsed
        at parseConnectionString (D:\My Files\university-mongoDB\M220JS\node_modules\mongodb\lib\core\uri_parser.js:542:21)
        at connect (D:\My Files\university-mongoDB\M220JS\node_modules\mongodb\lib\operations\connect.js:272:3)
        at cb (D:\My Files\university-mongoDB\M220JS\node_modules\mongodb\lib\mongo_client.js:221:5)
        at maybePromise (D:\My Files\university-mongoDB\M220JS\node_modules\mongodb\lib\utils.js:714:3)
        at MongoClient.connect (D:\My Files\university-mongoDB\M220JS\node_y-mongoDB\M220JS\node_modules\mongodb\lib\mongo_client.js:217:10)                                 ongoDB\M220JS\node_mod
        at Function.connect (D:\My Files\university-mongoDB\M220JS\node_modules\mongodb\lib\mongo_clie-mongoDB\M220JS\src/innt.js:427:22)
        at Object.<anonymous> (D:\My Files\universityer.js:701:30)-mongoDB\M220JS\src/index.js:23:13)              ngoDB\M220JS\node_modu
        at Module._compile (internal/modules/cjs/loader.js:701:30)                                    js/loader.js:712:10)  
        at Module._compile (D:\My Files\university-mobefore starting...    ngoDB\M220JS\node_modules\pirates\lib\index.js:99:24)
        at Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    [nodemon] app crashed - waiting for file changes 
    before starting...

I ran npm install , I found some error, and then I tried npm upgrade then packages downloaded successfully and then while I ran npm start, I am getting the above issue

The error message indicates that the URI is malformed.

It would be helpful to share the URI you used so that we can find what is wrong with your URI.

I think this is the one

SECRET_KEY=super_secret_key_you_should_change
MFLIX_DB_URI=mongodb+srv://m220student:m220password@<your-atlas-cluster-address>
MFLIX_NS=sample_mflix
PORT=5000

Is there any reason you did not replace

by your atlas cluster address.

mongodb+srv://taskappmanager:mypassword@cluster0-hibtv.mongodb.net/test?retryWrites=true&w=majority

I tried this it’s not working
this is my cluster address

You have the wrong password or username.

I have not provided the password, but I tried connecting through the command line and I was able to connect.

Humm

In the connection string

the following is the password

Why do you write

I have written my password, the same password I used in the command line for connecting i was able to connect

In my password I have * do I need to encode this in any way

Probably not

Hi there,
You should change SECRET_KEY and MFLIX_DB_URI, then change the filename to “.env”.

1 Like