Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
Are you running as root? You can't listen on a port <1024 unless you have root privileges - and I would strongly advise against that. – Nathan Osman Nov 14 '11 at 19:53
up vote 81 down vote accepted

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.

share|improve this answer
I might also add that running this command as root is not a good idea - it opens up all kinds of security vulnerabilities. – Nathan Osman Nov 14 '11 at 19:56
@cwd :) The TCP/IP port numbers below 1024 are special in that normal users are not allowed to run servers on them. This is a security feaure, in that if you connect to a service on one of these ports you can be fairly sure that you have the real thing, and not a fake which some hacker has put up for you. – James Nov 14 '11 at 20:17
@cwd If you want to run the server on a port <1024, use iptables to route incoming connections to a port ≥1024. For testing, do something like sudo nc -l 80 (netcat). And see Why are the first 1024 ports restricted to the root user only? – Gilles Nov 14 '11 at 23:42
@jrg A port <1024 only matters if you trust the sysadmin on the server but not other users. It's near-userless outside a few local networks nowadays: most servers aren't multiuser machines. – Gilles Nov 14 '11 at 23:43
This is a related question about how to drop privileges once you've opened port 80. – jcollado Nov 21 '11 at 22:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.