Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

python -m SimpleHTTPServer - Listening on 0.0.0.0:8000 but http://0.0.0.0:8000/test.html gives "Page Not Found"

Ask Question

in reply. But when I hit http://0.0.0.0:8000/test.html I get a page not found error.

I've also tried

pushd /path/you/want/to/serve; python -m SimpleHTTPServer; popd

taken from this question

When I hit ls I can see the file and the directory. Anyone know what I'm doing wrong?

I think the other two answers are trying to make it clear that 0.0.0.0 is not the URL you should be visiting. When a Python web server (like cherrypy for instance) says it is serving on 0.0.0.0 it means it is listening for all TCP traffic that ends up at that machine no matter the hostname or IP that was requested. But, if you change it such that the socket listens on 127.0.0.1 or 'localhost', then unless the request was specifically to that IP/hostname, it won't respond to the request. For example, many times you can use your machine name instead of localhost (ubuntu allows this for example). If your machine name is 'brian' and you have a server listening on 0.0.0.0:8080, you should be able to reach that server with http://brian:8080. But if that server is listening on 'localhost', even though 'brian' is set to point to 'localhost', the server won't receive the message.

You also need to be sure the file really is in the directory you are running the command from. Otherwise, the 404 response is actually correct :)

Good luck!

COMPUTERNAME.local:8000 works perfectly! Thanks. COMPUTERNAME is found in System Preferences > Sharing – Denis Hoctor Dec 3, 2010 at 3:03 Have now and thats not it. The thing is that 0.0.0.0:8000/ is showing a custom 'Page Not Found' message. – Denis Hoctor Dec 3, 2010 at 1:23

Try browsing to http://localhost:8000/test.html or http://127.0.0.1:8000/test.html (those two should be exactly the same thing as long as your hosts file isn't all crazy-like).

0.0.0.0 is usually used by Windows as the "Not connected" IP, and can also be used as a sort of wildcard for when dealing with IPs. I am a bit confused at why your HTTP server is trying to host on 0.0.0.0, though. You may need to edit some config files and set that to 'localhost' or '127.0.0.1'.

  • create a directory e.g. mkdir HTTPServer_dir
  • move inside the folder cd HTTPServer_dir
  • typing the command (according to python version) python -m SimpleHTTPSever 8000 (or the port you want)
  • go on a browser and type http://127.0.0.1:8000/
  • Done !!!

    You could make a simple index.html page inside the HTTPServer_dir so you can see an html page instead of directory listing

    Run ifconfig on Linux or ipconfig on Windows to find the ip address of the server.

    $ sudo ifconfig
    wlan0     Link encap:Ethernet  HWaddr 30:3a:64:b3:be:6a  
              inet addr:192.168.1.103  Bcast:192.168.1.255  Mask:255.255.255.0
    

    Here in case the url would be:

    http://192.168.1.103:8000/test.html

    Sometimes the same port number is used by some other service. So we can try with some other port like

    python -m SimpleHTTPServer 9090
    

    And then simply hit http://{your system IP}:9090/

    this works for me.

  • Go to the directory that your file is in.
  • python -m SimpleHTTPServer
    Shows "Serving HTTP on 0.0.0.0 port 8000 ..."
  • Now, find out your system name. For Windows 8: Control Panel -> System. You will see the computer name here. Let's say it is "Abhinav".

    Your local server will be hosted at "Abhinav.local:8000".

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.