Debian - Port 80 is blocked, but I don't know by what

22,027

Solution 1

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.

Solution 2

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.

Solution 3

Another option with fewer keystrokes is lsof:

lsof -i :80
Share:
22,027

Related videos on Youtube

Goot
Author by

Goot

Updated on September 18, 2022

Comments

  • Goot
    Goot over 1 year

    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
     failed!
    

    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?

  • Goot
    Goot about 11 years
    thanks, I figured out there is another instance of lighttpd running. I will accept your answer when it is possible.
  • poige
    poige about 11 years
    @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
    poige about 11 years
    Nope. It show not only listening processes.
  • poige
    poige about 11 years
    Correct use is a bit more longer: lsof -n -sTCP:LISTEN -i:22
  • poige
    poige about 11 years
    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.