I have a Java application and is unable to connect to database and other domains and failing with Network unreachable error. After adding DNS entries locally to /etc/hosts, the application is working fine.
As part of troubleshooting, I tried the connecting to other domains using CURL command and it worked all the time without any issues.
Question is why does Java code doesn’t able to resolve DNS?
One more thing is my server is running only on IPV6 address.
I wrote a simple java code to make HTTPS GET call to google.com and that is failing with timeout error. So is it a bug or something to do with DNS server?
java.net.SocketTimeoutException: connect timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:476) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:218) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:200) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394) at java.net.Socket.connect(Socket.java:606) at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:303) at sun.net.NetworkClient.doConnect(NetworkClient.java:175) at sun.net.www.http.HttpClient.openServer(HttpClient.java:499) at sun.net.www.http.HttpClient.openServer(HttpClient.java:594) at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:263) at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:366) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:207) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1167) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1061) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:193) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1584) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1512) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:352) at HttpConnectionTest.main(HttpConnectionTest.java:20)
gundaldo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.