Nginx Port 443 already in use by it self?

Kiksen asked:

I am totally new to Nginx and just playing around with my domain, that I had laying around and not used. Thought I might aswell put it to good use and host API on it. But wanted to learn some Nginx first.

When I check the error log I get the following error:

2020/09/07 10:49:54 [emerg] 32432#32432: bind() to failed (98: Address already in use)

When I check "sudo netstat -tulpn":

tcp        0      0   *               LISTEN      32455/nginx: master
tcp6       0      0 :::443                  :::*                    LISTEN      32455/nginx: master

It is nginx it self that is using the port 443?

My config is just overwriting the default nginx conf named "default" in sites-availble and looks like this:

server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;

ssl on;
ssl_certificate /home/ubuntu/dotnetdeploy/www_topswagcode_dev.pem;
ssl_certificate_key /home/ubuntu/dotnetdeploy/www_topswagcode_dev.key;

root /var/www/html;

index index.html index.htm index.nginx-debian.html;

server_name _;

location / {
    try_files $uri $uri/ =404;

After I changed my Config I ran:

sudo service nginx restart 

When I type:

nginx -T


then there is a lot of types eg:

types { ....  }


Anyone know what is going on here?

My answer:

You have another copy of nginx already running. You should kill it manually before trying to restart nginx using systemctl (stop using service as this is deprecated and will be removed eventually).

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.