Search code examples
htmlpython-3.xlocalserver

How Can I open an html file on a local server by using python (python -m http.server)?


When I try to run the following code in the directory where my index.html file is saved:

python -m http.server 8888

I get this error:
This site can’t be reachedThe webpage at http://0.0.0.0:8888/index.html might be temporarily down or it may have moved permanently to a new web address.
ERR_ADDRESS_INVALID

How can I solve this issue?
thanks


Solution

  • 0.0.0.0 is not a routable address. You put 0.0.0.0 on the command line sometimes to let the server know to listen on any interface. But to route to yourself, you must use the IP address 127.0.0.1.