Reputation: 337
I have created a server on my PC (localhost and port is 8080) and am trying to connect to it on my android device. But every time i try it gives me this error:
java.net.ConnectException: failed to connect to /10.0.2.2 (port 8080): connect failed: ETIMEDOUT (Connection timed out)
I have been looking online forever and looked at countless pages and have tried everything I could find.
-Switched the android host to 10.0.2.2
-Turned off firewall
-Changed the port
-Made sure both the PC and the android device where connected to the same internet connection
The Server code is written in Java and, just to make sure it works I tried making a connection to the server with another Java app. And it worked.
Thank you for your help, if you need any more info just let me know.
Upvotes: 7
Views: 8697
Reputation: 11214
Do not use 10.0.2.2. That is for if your app runs on an emulator.
Use the LAN ip of your pc.
Find out with ipconfig.
Upvotes: 6