How can I start the python SimpleHTTPServer on port 80?

I am using this command on Ubuntu but it is starting on port 8080 and I don’t have another server running so I’d like it to start on port 80. I saw ways that you could set up a bash script to do something like this, but isn’t there a command line flag or something simpler to specify the port?

python -m SimpleHTTPServer
Asked By: cwd


sudo python -m SimpleHTTPServer 80

for python 3.x version, you may need :

sudo python -m http.server 80

Ports below 1024 require root privileges.

As George added in a comment, running this command as root is not a good idea – it opens up all kinds of security vulnerabilities.

However, it answers the question.

Answered By: jrg

Do something like :

python -m SimpleHTTPServer 50505

Where 50505 is the port number.

Answered By: Akash Yellappa
Categories: Answers 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.