0

I have created AndroidWebServer on my android phone. When I try to access 192.168.1.150:8000 (phone address) I have good response from the server. But when I try to access the same url from the pc (connected via WiFi on the same network) nothing happens.

When the server is active if I run this

adb shell netstat -at

tcp        0      0 ::ffff:127.0.0.1:8000   :::*                    LISTEN 

That is weird because other services got foreign address

tcp        0      0 ::ffff:192.168.1.150:54 ::ffff:173.194.76.188:5 ESTABLISHED 
tcp        0      0 ::ffff:192.168.1.150:36 ::ffff:31.13.92.33:http ESTABLISHED 

for my service the foring address is :::*

I am not sure what I do wrong

https://github.com/lopspower/AndroidWebServer

AndroidWebServer androidWebServer = new AndroidWebServer(8000);
androidWebServer.start();

What should I change in order my phone to be accessible from my pc connected to the same WiFi network?

Thanks

Johns
  • 275
  • 1
  • 3
  • 5

1 Answers1

0

Looks like your server is listening on localhost. That means it will only accept connections that originate on the local machine. Try listening on 0.0.0.0 instead; that means you accept connections from all origins.

EDIT

Change this line:

AndroidWebServer androidWebServer = new AndroidWebServer("0.0.0.0", 8000);
greeble31
  • 4,894
  • 2
  • 16
  • 30