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

I try to sudo service nginx restart and it shows this error:

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

I think it is about this symlink?

ln -s ../sites-available/default default

I try

cd /etc/nginx && grep -R listen *

sites-available/default:        listen 80;
sites-enabled/default:        listen 80;

How do I fix it?



Solution 1:[1]

You can kill it using:

sudo fuser -k 80/tcp

And then try restarting nginx again:

service nginx start

Solution 2:[2]

For me it was because I had lighttpd installed, which was running. Uninstalled it and the problem disappeared.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 binhhoang18
Solution 2 gitaarik