Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

If I run: service nginx restart I have 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 to fix it? I have also apache conf running on port 80.

share|improve this question
1  
why do you need two different servers? Assuming you do, don't use the same port for both. –  dawud Jul 3 '13 at 10:14

3 Answers 3

You can't bind both Apache and Nginx on the same port 80/tcp.

share|improve this answer
    
How to change nginx to another port? –  user2426362 Jul 3 '13 at 10:27
    
Change the directive listen 80 in your server/virtualhost section –  fsoppelsa Jul 3 '13 at 10:33
    
nano /etc/nginx/sites-enabled/default and I added listen 44444 but sill is 80 (the same error like in question) –  user2426362 Jul 3 '13 at 12:22
    
What else can I do? –  user2426362 Jul 3 '13 at 12:34
    
Be sure there are no listen directives duplicates, then restart Nginx. –  fsoppelsa Jul 3 '13 at 12:45

You cannot run two applications listening on same port, in this instance on port 80. You can either change the port for apache or for nginx

share|improve this answer

You can use something like the following

server {
    listen xxx.xxx.xxx.xxx:8080;

P.S. it is good practice to use nginx like a frontend and apache like a backend.

share|improve this answer
    
Or apache to serve static file + nginx to serve server-side scripting. –  fsoppelsa Jul 3 '13 at 12:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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