Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleHTTPServer: other devices can't connect to the server

Lately I've been playing with Python to discover its potential and I've just stumbled upon SimpleHTTPServer.

I'm on Windows 10.

I run:

python -m SimpleHTTPServer

the output is:

Serving HTTP on 0.0.0.0 port 8000 ... 

I've opened the browser both on smartphone and tablet, but none of them can connect to the server when I type "http://127.0.0.1:8000".

(Translating from italian, maybe is not the exact translation)

iPad: "Safari can't open the page because the server has stopped responding"

Android: "WebPage does not respond. the webpage may be temporarily not available or it could have been moved to another address"

Why does it not work? How do I fix this?

like image 464
Pigna Avatar asked Feb 08 '16 22:02

Pigna


2 Answers

Maybe your firewall is blocking access to python based server

Try this:

  • Open windows firewall
  • click on "allow an app or feature..." on the left side of the opened window
  • search for python in the list and check both the boxes private and public

It should work now

like image 95
Ankit kumar Avatar answered Oct 03 '22 20:10

Ankit kumar


127.0.0.1 is always the IP address of the local system (its associated hostname is "localhost"). In other words, if you type 127.0.0.1:8000 on your tablet or Android device, the browser on that device will try to connect to a server running on the same device, listening on port 8000. You'll need to find out the IP address of the computer you're running Python on, and type that instead. You can use the ifconfig command on Unix, or ipconfig on Windows.

like image 20
James Scholes Avatar answered Oct 03 '22 22:10

James Scholes