Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.net.ConnectException

When I'm running my app through Google Nexus by connecting through USB and trying to connect webservice running on my laptop then I'm getting below error but I'm able to connect to webservie. Please advice.

     java.net.ConnectException: failed to connect to /192.168.1.122 (port 8080):       
           connect failed: ENETUNREACH (Network is unreachable)

            at libcore.io.IoBridge.connect(IoBridge.java:114)
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
            at java.net.Socket.startupSocket(Socket.java:566)
            at java.net.Socket.tryAllAddresses(Socket.java:127)
            at java.net.Socket.<init>(Socket.java:177)
            at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
            at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
            at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
            at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
            at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
            at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
            at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
like image 717
Sam Avatar asked Nov 03 '22 04:11

Sam


1 Answers

Just because you connect the phone to the computer don't mean that it will create a network connection.

Create a LAN run the web-service on the LAN IP. and use wifi to connect to it.

like image 142
Thihara Avatar answered Nov 15 '22 00:11

Thihara