title: How to stop nginx from using port 80
body: <p>I'm trying to update <a href="https://nginx.org/en/" rel="noreferrer">nginx</a> using <code>sudo apt-get install nginx</code>, but it is giving me an error message related to port 80 being occupied. When I run</p>
  
  <pre><code>sudo netstat -tlnp | grep 80
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Although I wasn't able to easily understand what each column means from the <code>--help</code> function, I suppose that in this example <code>6845</code> is the process ID of <code>nginx</code>. If I try to kill it using</p>
  
  <pre><code>sudo kill 6845
  </code></pre>
  
  <p>and run <code>sudo netstat -tlnp | grep 80</code> again, I see</p>
  
  <pre><code>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
  </code></pre>
  
  <p>In other words, it seems like <code>nginx</code> has immediately started listening on port 80 again under a different process ID. How can I stop <code>nginx</code> from running? (I've also tried <code>sudo systemctl stop nginx</code> but to no avail).</p>