title: nginx doesn't listen on port 80 twice?
body: <h2>Edit: Read this, first:</h2>
  
  <p>Apart from the accepted answer, these errors occur when nginx is started <em>without</em> systemd.  Kill nginx: <code>ps -ax | grep nginx</code> → find the <kbd>nginx master pid</kbd> → <code>kill ###</code>; run nginx <em>with</em> systemd: <code>systemctl start nginx</code>.</p>
  
  <p>If systemctl is not used to start nginx, systemctl stop nginx doesn't seem to work (at least on my server); so, systemctl restart nginx gives this error when it tries to start nginx a second time.</p>
  
  <h2>About my setup:</h2>
  
  <p>I'm on Debian 10, Buster, with a live server.  I have tested both domain names, and they broadcast by themselves using these config files, but they do not broadcast when both config files are active.</p>
  
  <h2>What I'm trying to accomplish:</h2>
  
  <p>How do I set up two websites on a single ip address using nginx?</p>
  
  <h2>Error message(s):</h2>
  
  <p><code>nginx: [emerg] a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/example.com:22</code> line 2.</p>
  
  <p><code>nginx: [emerg] a duplicate default server for 0.0.0.0:443 in /etc/nginx/sites-enabled/example.com:22</code> line 2. <code>default_server</code> is used on port 443.</p>
  
  <p><code>nginx: [emerg] duplicate listen options for [::]:443 in /etc/nginx/sites-enabled/example.com:23</code> line 3. <code>default_server</code> tried as <code>http2</code> in one file and port 443 is used.</p>
  
  <p><code>nginx: [emerg] duplicate listen options for [::]:80 in /etc/nginx/sites-enabled/example.com:23</code> line 3. <code>default_server</code> tried as <code>http2</code> in one file.</p>
  
  <p><code>nginx: [emerg] invalid parameter "example.com" in /etc/nginx/sites-enabled/example.com:23</code> line 3: <code>default_server</code> tried as <code>example.com</code></p>
  
  <h2>Config files (comments stripped):</h2>
  
  <p><strong><em>There are two of these files (code seen below)</em></strong>.  My config files are exactly as-seen in the code block below with only one difference: in both files, <code>example.com</code> is a real, unique domain name that I own.</p>
  
  <p>My config files live in <code>/etc/nginx/sites-available</code>, and they are symlinked to <code>/etc/nginx/sites-enabled</code>.</p>
  
  <pre><code>server {
      listen 80 default_server;
      listen [::]:80 default_server ipv6only=on;
  
      root /var/www/example.com; #example.com is different in both files.
      index index.html index.htm index.nginx-debian.html;
  
      server_name example.com www.example.com; #example.com is different in both files.
  
      location / {
          try_files $uri $uri/ =404;
      }
  }
  </code></pre>
  
  <h2>Primary dissonance:</h2>
  
  <p><a href="https://stackoverflow.com/a/15101745/445651">Another stack question</a> says to rewrite these lines or comment one of them out.  The rewrites either do not resolve the error or result in a situation where files are not publicly served (example.com goes nowhere).</p>
  
  <h2>Summary:</h2>
  
  <p>This question seems to be about line 2, line 3, or line 2 and 3.</p>
  
  <p>Essentially, all of the leading how-to's either expressly tell the reader to use the code above <em>-or-</em> they don't mention these lines.</p>