title: nginx won't stop/restart failed (98: Address already in use)
body: <p>Versions:
  This is a fresh turn up of a Ubuntu 14.04
  NGINX 1.4.6</p>
  
  <p>Summary:
  issuing service nginx stop, does not stop the server, issuing nginx restart provides a fail! with an error of already in use.</p>
  
  <p>Details:
  I believe this is an issue with my vhosts, if i comment out the include for sites-enabled in the nginx.conf, it all behaves properly. I have read multiple sites stating about ipv6only and ipv4, but that appears to be fine, as this is the out of the box default</p>
  
  <p>Apache is not installed, nginx is the only server.</p>
  
  <p>Debugging:</p>
  
  <pre><code>nginx -t
  nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  nginx: configuration file /etc/nginx/nginx.conf test is successful
  
  lsof -i :80
  
  COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
  nginx   1208     root    7u  IPv4  10246      0t0  TCP *:http (LISTEN)
  nginx   1208     root    8u  IPv6  10247      0t0  TCP *:http (LISTEN)
  nginx   1209 www-data    7u  IPv4  10246      0t0  TCP *:http (LISTEN)
  nginx   1209 www-data    8u  IPv6  10247      0t0  TCP *:http (LISTEN)
  nginx   1210 www-data    7u  IPv4  10246      0t0  TCP *:http (LISTEN)
  nginx   1210 www-data    8u  IPv6  10247      0t0  TCP *:http (LISTEN)
  
  service nginx stop
  
  lsof -i :80
  
  COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
  nginx   1208     root    7u  IPv4  10246      0t0  TCP *:http (LISTEN)
  nginx   1208     root    8u  IPv6  10247      0t0  TCP *:http (LISTEN)
  nginx   1209 www-data    7u  IPv4  10246      0t0  TCP *:http (LISTEN)
  nginx   1209 www-data    8u  IPv6  10247      0t0  TCP *:http (LISTEN)
  nginx   1210 www-data    7u  IPv4  10246      0t0  TCP *:http (LISTEN)
  nginx   1210 www-data    8u  IPv6  10247      0t0  TCP *:http (LISTEN)
  
  service nginx restart
   * Restarting nginx nginx
   ...fail!
  </code></pre>
  
  <p>error-log:</p>
  
  <pre><code>2015/05/14 14:58:48 [emerg] 14620#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
  2015/05/14 14:58:48 [emerg] 14620#0: bind() to [::]:80 failed (98: Address already in use)
  2015/05/14 14:58:48 [emerg] 14620#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
  2015/05/14 14:58:48 [emerg] 14620#0: bind() to [::]:80 failed (98: Address already in use)
  2015/05/14 14:58:48 [emerg] 14620#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
  2015/05/14 14:58:48 [emerg] 14620#0: bind() to [::]:80 failed (98: Address already in use)
  2015/05/14 14:58:48 [emerg] 14620#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
  2015/05/14 14:58:48 [emerg] 14620#0: bind() to [::]:80 failed (98: Address already in use)
  2015/05/14 14:58:48 [emerg] 14620#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
  2015/05/14 14:58:48 [emerg] 14620#0: bind() to [::]:80 failed (98: Address already in use)
  2015/05/14 14:58:48 [emerg] 14620#0: still could not bind()
  </code></pre>
  
  <p>Conf Files:
  nginx.conf</p>
  
  <pre><code>user www-data;
  worker_processes 2;
  pid /var/run/nginx.pid;
  
  events {
      worker_connections 2048;
      use epoll;
      multi_accept on;
  }
  
  http {
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;
      keepalive_timeout 10;
      send_timeout 2;
      types_hash_max_size 2048;
      server_tokens off;
  
      client_max_body_size 5M;
      client_body_buffer_size 256k;
  
      include /etc/nginx/mime.types;
      default_type application/octet-stream;
  
      #access_log /var/log/nginx/access.log;
      access_log off;
      error_log /var/log/nginx/error.log;
  
      gzip on;
      gzip_disable "msie6";
      proxy_set_header Accept-Encoding "";
  
      proxy_set_header Connection "";
      proxy_http_version 1.1;
  
      open_file_cache max=1000 inactive=20s;
      open_file_cache_valid 30s;
      open_file_cache_min_uses 5;
      open_file_cache_errors off;
  
      reset_timedout_connection on;
  
      include /etc/nginx/conf.d/*.conf;
      include /etc/nginx/sites-enabled/*;
  }
  </code></pre>
  
  <p>sites-available/default</p>
  
  <pre><code> server {
      listen 80 default_server;
      listen [::]:80 ipv6only=on default_server;
  
      #listen [::]:80 ipv6only=on; # listen for IPv6 only traffic on IPv6 sockets
      #listen 80; # listen also for IPv4 traffic on "regular" IPv4 sockets
  
      root /usr/share/nginx/html;
      index index.html index.htm;
  
      # Make site accessible from http://localhost/
      server_name localhost;
  
      location / {
              # First attempt to serve request as file, then
              # as directory, then fall back to displaying a 404.
              try_files $uri $uri/ =404;
              # Uncomment to enable naxsi on this location
              # include /etc/nginx/naxsi.rules
      }
  }
  </code></pre>