SimpleHTTPServer: other devices can't connect to the server

Question:

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?

Asked By: Pigna

||

Answers:

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.

Answered By: James Scholes

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

Answered By: Ankit kumar
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.