Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Socket Connection Refused ETIMEDOUT (Connection timed out)

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.

like image 353
Grobbed Avatar asked Jun 03 '15 04:06

Grobbed


1 Answers

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.

like image 94
greenapps Avatar answered Sep 19 '22 00:09

greenapps