Python SimpleHTTPServer doesn't work - A server error occurred

14.9k views Asked by At

I've just tried to run python -m SimpleHTTPServer 8000 in a directory where I have some basic web files. It seems to run fine at first, on the command line it prints:

Serving HTTP on 0.0.0.0 port 8000 ...

However, when I try to view my page on http://127.0.0.1:8000 in browser, I get this error message:

A server error occurred. Please contact the administrator.

Sorry if this seems vague, but I'm not a Python developer so I have no idea why it's not working. Do you have any ideas why or how to start debugging this issue?

2

There are 2 answers

3
Paulo Bu On BEST ANSWER

If you aren't seeing anything on the command line, then the server is not getting any input. You must have some other process listening on that port. Try a different port just to be sure:

python -m SimpleHTTPServer 12345

Just a tip, to check what applications you have listening on which port, netstat command can be very useful :)

Hope this helps!

0
Jonas-Carvalho On

Try the following code for Python 3 version:

python -m http.server