Details
-
Bug
-
Resolution: Duplicate
-
Minor - P4
-
None
-
None
-
None
-
None
Description
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.
Attachments
Issue Links
- duplicates
-
JAVA-249 Java Driver cannot connect to 'localhost' when mongod is listening only on 127.0.0.1 (or "localhost")
-
- Closed
-