-
Type: Bug
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
If the machine's hostname does not resolve, then the following line will cause an UnknownHostException:
ServerAddress sa=new ServerAddress("mongodb://localhost:27017");
That's because the constructor for ServerAddress recognises the string "localhost" and calls InetAddress.getLocalHost(). This issue does not occur if you use "127.0.0.1" instead of "localhost".
If you feel this is intended behavior, would you consider noting it in the documentation.
- duplicates
-
JAVA-249 Java Driver cannot connect to 'localhost' when mongod is listening only on 127.0.0.1 (or "localhost")
- Closed