Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx will not start (Address already in use)

Tags:

nginx

I have a problem with nginx. I tried different solutions, but for me nothing work. That is my error:

4 root@BANANAS ~ # sudo service nginx restart                                :( Restarting nginx: nginx: [emerg] bind() to [::]:443 failed (98: Address already in use) nginx: [emerg] bind() to [::]:443 failed (98: Address already in use) nginx: [emerg] bind() to [::]:443 failed (98: Address already in use) nginx: [emerg] bind() to [::]:443 failed (98: Address already in use) nginx: [emerg] bind() to [::]:443 failed (98: Address already in use) nginx: [emerg] still could not bind() nginx. 

Can you help me?

like image 361
Herbert89 Avatar asked Feb 17 '17 16:02

Herbert89


People also ask

How do I check my Nginx status?

Through a simple command you can verify the status of the Nginx configuration file: $ sudo systemctl config nginx The output will show if the configuration file is correct or, if it is not, it will show the file and the line where the problem is.


1 Answers

Probably other process is using specified port:

sudo netstat -tulpn 

Get the PID of the process that already using 443. And send signal with kill command.

sudo kill -2 <PID>  sudo service nginx restart 

Aternatively you can do:

sudo fuser -k 443/tcp 

Make sure you dont use old syntax:

server {     listen :80;     listen [::]:80; } 

The above syntax will cause

nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) 

Correct syntax:

server {     listen 80;     listen [::]:80 ipv6only=on; } 

or

server {     listen [::]:80; } 

Both above syntax will achieve the same thing, listening on both ipv4 and ipv6.

like image 104
Farhad Farahi Avatar answered Sep 26 '22 04:09

Farhad Farahi