-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URI does not have hostname, domain name and tld #19
Comments
I am new in Mongodb and now I face a problem with mongodb when create connection with node js to mongodb atlas display following error connection error: { MongoParseError: URI does not have hostname, domain name and tld |
Yeah It is because of using special characters in passwords ,just use this simple method either using the above complicated codes for encoding. In the Password use Hex code instead of symbols which you are using in password like if your password in text is:- pass123# so use it like:- pass123%23 |
Thanks Anonsatyam. . . i was getting the same error for days and this really solved my problem |
Hey guys. const { MongoClient } = require("mongodb"); // Replace the uri string with your MongoDB deployment's connection string. const client = new MongoClient(uri); async function run() {
} finally {
what am I missing? help would be highly appreciated! |
Thanks, it Worked 👍 |
Thanks for saving my day ,it works |
You just saved my entire day, I was searching this solution for 2 hours . |
The 2 main root causes of that issue are linked to :
|
i have same problem but i got it |
Can you please suggest how do i update that password? |
This was very accurate. Thank you |
Here are the Hex code of some Special characters (Use them after % ) |
Facing same issue but its not related to password in my case. Still stuck need some assistance. "C:\Program Files\Java\jdk-17\bin\java.exe" "-javaagent:D:\Intellij 2023.1\IntelliJ IDEA Community Edition 2023.1.1\lib\idea_rt.jar=55990:D:\Intellij 2023.1\IntelliJ IDEA Community Edition 2023.1.1\bin" -Dfile.encoding=UTF-8 -classpath "D:\Movies api\movies\movies\target\classes;C:\Users\anurbhar.m2\repository\org\springframework\boot\spring-boot-starter-data-mongodb\2.7.12\spring-boot-starter-data-mongodb-2.7.12.jar;C:\Users\anurbhar.m2\repository\org\springframework\boot\spring-boot-starter\2.7.12\spring-boot-starter-2.7.12.jar;C:\Users\anurbhar.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.7.12\spring-boot-starter-logging-2.7.12.jar;C:\Users\anurbhar.m2\repository\ch\qos\logback\logback-classic\1.2.12\logback-classic-1.2.12.jar;C:\Users\anurbhar.m2\repository\ch\qos\logback\logback-core\1.2.12\logback-core-1.2.12.jar;C:\Users\anurbhar.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.17.2\log4j-to-slf4j-2.17.2.jar;C:\Users\anurbhar.m2\repository\org\apache\logging\log4j\log4j-api\2.17.2\log4j-api-2.17.2.jar;C:\Users\anurbhar.m2\repository\org\slf4j\jul-to-slf4j\1.7.36\jul-to-slf4j-1.7.36.jar;C:\Users\anurbhar.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\anurbhar.m2\repository\org\yaml\snakeyaml\1.30\snakeyaml-1.30.jar;C:\Users\anurbhar.m2\repository\org\mongodb\mongodb-driver-sync\4.6.1\mongodb-driver-sync-4.6.1.jar;C:\Users\anurbhar.m2\repository\org\mongodb\bson\4.6.1\bson-4.6.1.jar;C:\Users\anurbhar.m2\repository\org\mongodb\mongodb-driver-core\4.6.1\mongodb-driver-core-4.6.1.jar;C:\Users\anurbhar.m2\repository\org\mongodb\bson-record-codec\4.6.1\bson-record-codec-4.6.1.jar;C:\Users\anurbhar.m2\repository\org\springframework\data\spring-data-mongodb\3.4.12\spring-data-mongodb-3.4.12.jar;C:\Users\anurbhar.m2\repository\org\springframework\spring-tx\5.3.27\spring-tx-5.3.27.jar;C:\Users\anurbhar.m2\repository\org\springframework\spring-context\5.3.27\spring-context-5.3.27.jar;C:\Users\anurbhar.m2\repository\org\springframework\spring-beans\5.3.27\spring-beans-5.3.27.jar;C:\Users\anurbhar.m2\repository\org\springframework\spring-expression\5.3.27\spring-expression-5.3.27.jar;C:\Users\anurbhar.m2\repository\org\springframework\data\spring-data-commons\2.7.12\spring-data-commons-2.7.12.jar;C:\Users\anurbhar.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\anurbhar.m2\repository\org\springframework\boot\spring-boot-starter-web\2.7.12\spring-boot-starter-web-2.7.12.jar;C:\Users\anurbhar.m2\repository\org\springframework\boot\spring-boot-starter-json\2.7.12\spring-boot-starter-json-2.7.12.jar;C:\Users\anurbhar.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.13.5\jackson-databind-2.13.5.jar;C:\Users\anurbhar.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.13.5\jackson-annotations-2.13.5.jar;C:\Users\anurbhar.m2\repository\com\fasterxml\jackson\core\jackson-core\2.13.5\jackson-core-2.13.5.jar;C:\Users\anurbhar.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.13.5\jackson-datatype-jdk8-2.13.5.jar;C:\Users\anurbhar.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.13.5\jackson-datatype-jsr310-2.13.5.jar;C:\Users\anurbhar.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.13.5\jackson-module-parameter-names-2.13.5.jar;C:\Users\anurbhar.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.7.12\spring-boot-starter-tomcat-2.7.12.jar;C:\Users\anurbhar.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.75\tomcat-embed-core-9.0.75.jar;C:\Users\anurbhar.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.75\tomcat-embed-el-9.0.75.jar;C:\Users\anurbhar.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.75\tomcat-embed-websocket-9.0.75.jar;C:\Users\anurbhar.m2\repository\org\springframework\spring-web\5.3.27\spring-web-5.3.27.jar;C:\Users\anurbhar.m2\repository\org\springframework\spring-webmvc\5.3.27\spring-webmvc-5.3.27.jar;C:\Users\anurbhar.m2\repository\org\springframework\spring-aop\5.3.27\spring-aop-5.3.27.jar;C:\Users\anurbhar.m2\repository\org\springframework\boot\spring-boot-devtools\2.7.12\spring-boot-devtools-2.7.12.jar;C:\Users\anurbhar.m2\repository\org\springframework\boot\spring-boot\2.7.12\spring-boot-2.7.12.jar;C:\Users\anurbhar.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.7.12\spring-boot-autoconfigure-2.7.12.jar;C:\Users\anurbhar.m2\repository\org\projectlombok\lombok\1.18.26\lombok-1.18.26.jar;C:\Users\anurbhar.m2\repository\org\springframework\spring-core\5.3.27\spring-core-5.3.27.jar;C:\Users\anurbhar.m2\repository\org\springframework\spring-jcl\5.3.27\spring-jcl-5.3.27.jar" dev.anurag.movies.MoviesApplication . ____ _ __ _ _ 2023-05-22 13:32:25.602 INFO 16668 --- [ restartedMain] dev.anurag.movies.MoviesApplication : Starting MoviesApplication using Java 17.0.7 on ANURBHAR-7420 with PID 16668 (D:\Movies api\movies\movies\target\classes started by anurbhar in D:\Movies api\movies\movies) Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'movieController': Unsatisfied dependency expressed through field 'movieService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'movieService': Unsatisfied dependency expressed through field 'movieRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'movieRepository' defined in dev.anurag.movies.MovieRepository defined in @EnableMongoRepositories declared on MongoRepositoriesRegistrar.EnableMongoRepositoriesConfiguration: Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryDependentConfiguration.class]: Unsatisfied dependency expressed through method 'mongoTemplate' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mongoDatabaseFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryConfiguration.class]: Unsatisfied dependency expressed through method 'mongoDatabaseFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongo' defined in class path resource [org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.client.MongoClient]: Factory method 'mongo' threw exception; nested exception is java.lang.IllegalArgumentException: An SRV host name '${env.MONGO_CLUSTER}' was provided that does not contain at least three parts. It must contain a hostname, domain name and a top level domain. Process finished with exit code 0 |
Hey @bhardwajanurag21! I'm going through the same project right now and I'm stuck at the same step. Were you able to solve this issue? |
MongoParseError: URI does not have hostname, domain name and tld
at parseSrvConnectionString (E:\Projects\NodeAPI\node_modules\mongodb-core\lib\uri_parser.js:41:21)
at parseConnectionString (E:\Projects\NodeAPI\node_modules\mongodb-core\lib\uri_parser.js:509:12)
at connect (E:\Projects\NodeAPI\node_modules\mongodb\lib\operations\mongo_client_ops.js:195:3)
at connectOp (E:\Projects\NodeAPI\node_modules\mongodb\lib\operations\mongo_client_ops.js:284:3)
at executeOperation (E:\Projects\NodeAPI\node_modules\mongodb\lib\utils.js:416:24)
at MongoClient.connect (E:\Projects\NodeAPI\node_modules\mongodb\lib\mongo_client.js:175:10)
at Function.MongoClient.connect (E:\Projects\NodeAPI\node_modules\mongodb\lib\mongo_client.js:341:22)
at Object. (E:\Projects\NodeAPI\server.js:12:13)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
name: 'MongoParseError',
[Symbol(mongoErrorContextSymbol)]: {} }
The text was updated successfully, but these errors were encountered: