MongoParseError: URI does not have hostname, domain name and tld

Can someone please help me out. I keep getting this error message after updating the env file. Also I’m not sure if the @ symbol is included before the URI. I’ve been stuck here for 2 days now

apples-MBP:mflix-js apple$ npm start

server@1.0.0 start /Users/apple/Desktop/M220JS-Javascript/Handouts/mflix-js
nodemon -L ./index.js

[nodemon] 1.19.1
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node ./index.js
MongoParseError: URI does not have hostname, domain name and tld
at parseSrvConnectionString (/Users/apple/Desktop/M220JS-Javascript/Handouts/mflix-js/node_modules/mongodb/lib/core/uri_parser.js:41:21)
at parseConnectionString (/Users/apple/Desktop/M220JS-Javascript/Handouts/mflix-js/node_modules/mongodb/lib/core/uri_parser.js:516:12)
at connect (/Users/apple/Desktop/M220JS-Javascript/Handouts/mflix-js/node_modules/mongodb/lib/operations/connect.js:266:3)
at ConnectOperation.execute (/Users/apple/Desktop/M220JS-Javascript/Handouts/mflix-js/node_modules/mongodb/lib/operations/connect.js:191:5)
at /Users/apple/Desktop/M220JS-Javascript/Handouts/mflix-js/node_modules/mongodb/lib/operations/execute_operation.js:109:26
at new Promise ()
at executeOperation (/Users/apple/Desktop/M220JS-Javascript/Handouts/mflix-js/node_modules/mongodb/lib/operations/execute_operation.js:102:10)
at MongoClient.connect (/Users/apple/Desktop/M220JS-Javascript/Handouts/mflix-js/node_modules/mongodb/lib/mongo_client.js:216:10)
at Function.MongoClient.connect (/Users/apple/Desktop/M220JS-Javascript/Handouts/mflix-js/node_modules/mongodb/lib/mongo_client.js:379:22)
at Object.connect (/Users/apple/Desktop/M220JS-Javascript/Handouts/mflix-js/src/index.js:23:13)
[nodemon] app crashed - waiting for file changes before starting…

It would help if you share the URI you are using.

mongodb+srv://m220student:@mflix-fhl5s.mongodb.net/test?retryWrites=true&w=majority

actually im confused on a couple of issues. First is the URI. I copied the URI on the top bar after I logged into the cluster, the i get that error message. Then I copied the string provided when you want to connect the application
mongodb+srv://m220student:@mflix-fhl5s.mongodb.net/test?retryWrites=true&w=majority
and I get a different error message this time.

Hi @Akong,

Did you update the password in URI string ? If not, replace PASSWORD with the actual password and then try again.

mongodb+srv://m220student:@PASSWORDmflix-fhl5s.mongodb.net/test?retryWrites=true&w=majority 

Kanika

ok i found the problem. It had to do with whitelisting IP.
thanks

1 Like