I can't make lighttpd listen to port 80.

~# /etc/init.d/lighttpd start
Starting web server: lighttpd2013-03-16 23:15:02: (network.c.379) can't bind to port:  80 Address already in use

Actually I have apache2 installed on my server, too (listening to port 80) but it is not active.

I used netstat / netstat -npl but it wasn't helpful

How can I figure out what is using the port?


In depsite of people got used to netstat for such kind of operations, it's good to know, that Linux has another great (and, actually superior) networking tool — ss. For e. g., to find out which process has opened port 80 you run it so:

sudo ss -pt state listening 'sport = :80'

so there's no need to pipe through external filters. Surely it has lots more useful knobs, so get yourself familiar with it.

For completeness sake and since recently I came across man fuser, I can also mention:

  • sudo fuser 80/tcp — this one also saves you from tinkering at cut/grep/awk… keep in mind this notation is a short-cut, in case there's an ambiguity, you should use one of namespaces allowed with -n …, like sudo fuser -n tcp 80

  • sudo lsof -n -sTCP:LISTEN -i:80 — was pointed out by @wallenborn. Meanwhile -n is not strictly required it's strongly advised since otherwise it uses DNS resolving which usualy slows down output terribly.

  • @Goot, if you mean binary, yep, at least ls -l /proc/PID/exe would do. And you mean its current work dir, see …/cwd. – poige Mar 16 '13 at 19:41

Address already in use means that another process is already listening on port 80. Only one process can listen on a given port at a time.

To find the process, run as root:

netstat -tnlp | grep -w 80

The offending process will be listed.

  • thanks, I figured out there is another instance of lighttpd running. I will accept your answer when it is possible. – Goot Mar 16 '13 at 19:33

Another option with fewer keystrokes is lsof:

lsof -i :80
  • Nope. It show not only listening processes. – poige Mar 18 '13 at 0:56
  • 1
    Correct use is a bit more longer: lsof -n -sTCP:LISTEN -i:22 – poige Mar 18 '13 at 1:08
  • 1
    Correct use is a bit more longer: sudo lsof -n -sTCP:LISTEN -i:80. And it's better to use sudo explicitly to emphasize that unless user has superior permissions he might not be able to get correct results. – poige Mar 18 '13 at 1:14

Old thread but who knows, someone has the same problem I had. In Apache2 I had more than one site enabled. In one of the site configurations (/etc/apache2/sites-available) the first line was

listen 80

This caused a conflict with Apache itself! Because it was already listening on port 80 as a global config. Just remove the 'listen 80' from yoursite.conf if Apache has port 80 as a default port.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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