2

I'm trying to run service nginx restart but I get this error:

root@user /etc/nginx/sites-enabled # service nginx restart
Restarting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
nginx.

How can I fix this problem? I'm also running apache.

3

You can't have more than one application listening to a port on a device. You have the following choices:

  1. Remove Nginx or Apache. Just use one.

  2. Keep both and move Apache or Nginx to another port. From there you can have the port80 server proxy the other one so that it is available for certain domains (see proxy_pass or mod_proxy).

  3. Keep both and move Apache and Nginx onto distinct IP addresses or interfaces. If your server is configured to have 10.0.0.3 and 10.0.0.4 (just examples) you could give the first to Apache and the second to Nginx and both could have a port80 on their respective IPs. This has knock-on consequences for DNS but that's not hard to account for.

    This does mean you need to stop using 0.0.0.0 as a setting in both servers.

1

You will need to change the configure port of either Apache or Nginx. After you do this you will need to restart the reconfigured servers, using the 'service' command you used.

Apache

Edit /etc/apache2/ports.conf and change the 80 on the following line:

Listen 80

for something different.

Nginx

Edit /etc/nginx/sites-enabled/default and change the 80 on the following line:

listen 80;

for something different, this should be near the top, and be in the first server { section.

  • Thanks. I don't have server{} section in this file (nginx.conf) dpaste.de/6XSoI - here is my full config – user2426362 Jul 3 '13 at 11:29
  • Oh, Sorry, I meant /etc/nginx/sites-enabled/default – Micheal Harker Jul 3 '13 at 11:41
  • Thx. Still the same error :( I don't know what is wrong. – user2426362 Jul 3 '13 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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