I’m trying to update nginx using sudo apt-get install nginx
, but it is giving me an error message related to port 80 being occupied. When I run
sudo netstat -tlnp | grep 80
I get
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6845/nginx tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 1919/config.ru tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 6845/nginx
Although I wasn’t able to easily understand what each column means from the --help
function, I suppose that in this example 6845
is the process ID of nginx
. If I try to kill it using
sudo kill 6845
and run sudo netstat -tlnp | grep 80
again, I see
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10130/nginx tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 1919/config.ru tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 10130/nginx
In other words, it seems like nginx
has immediately started listening on port 80 again under a different process ID. How can I stop nginx
from running? (I’ve also tried sudo systemctl stop nginx
but to no avail).
Advertisement
Answer
I managed to solve the problem by going to 127.0.0.1:80
in my browser, which brought me to a GitLab login page. I had forgotten that I had once installed GitLab but wasn’t using it. After uninstalling GitLab, port 80 was no longer occupied.