this made me crazy! I want to use nginx on port 81 and apache on 80. apache works correctly but when I want to start nginx I get this error:

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

but I didn't configured any site on port 80 in nginx!

server {
    listen       81  default_server;
    listen   [::]:81 default_server  ipv6only=on;
    server_name  _;
    return       444;
}

server {

        listen   81; ## listen for ipv4

        server_name  domain.com;
        root   /home/domain/public_html/;

        location / {

        }

.
.
.
}

note that I have not any other file in sites-available an sites-enabled folders.

  • Do you have /etc/nginx/sites-enabled/default? – Alexey Ten Dec 30 '14 at 10:50
  • 1
    You have an unshown server block with listen 80 - just delete it. note that I have not any other file in sites-available an sites-enabled folders. maybe true - but there will be another server block in the nginx conf listening to 80 and only you can find it. – AD7six Dec 30 '14 at 11:47

I found a conf file in conf.d folder listening to 80.

You can use grep -slir "listen 80" . to find all files with a common pattern in that directory you are in. Its very helpfull to find such problems if there are some dublicated entries.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.