Can't listen on port 80 with my server Can't listen on port 80 with my server unix unix

Can't listen on port 80 with my server


If this is Linux (and perhaps some other UNIXes as well, though not MacOS), try running the following:

sudo netstat -lnp

You'll get output similar to the following:

Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   ...tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     26156/apache2       ...

I'll list the interesting parts:

  • Local Address: 0.0.0.0:80 - The address in question is port 80 on all interfaces.
  • State: LISTEN - It's listening
  • PID/Program name - 26156/apache2 - The ID and name of the process that's listening to the port.

You basically want to to make sure the program mentioned above isn't running (e.g., in my case, I'd have to shutdown the apache2 daemon, and configure the OS to not automatically start it up on next boot).

On the other hand, if you just want to get this fixed quickly, you can kill the process:

kill -9 <pid>

In my example:

kill -9 26156

The problem will of course return the next time you reboot, or someone starts up that service.


You can use lsof to find out:

sudo lsof -i :80

If you don't have lsof, install it with

sudo apt-get install lsof

lsof is like swiss army knife tool to tell who is holding files and sockets open.