Serge Kvashnin
Serge Kvashnin

Reputation: 4491

Nginx(proxy) + Apache: two process listening same port

I have two servers on CentOS: Nginx(proxy) + Apache. I need restart Nginx but if i try to test configuration before restart, i have next error:

[root@vm5808 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
nginx: configuration file /etc/nginx/nginx.conf test failed

How i can solve this problem? Thanks!

P.S. Nginx has listen port 80, apache listen 81.

Upvotes: 2

Views: 4120

Answers (3)

Serge Kvashnin
Serge Kvashnin

Reputation: 4491

I don't know why this error has appeared, but after I made

[root@vm5808 ~]# /etc/init.d/nginx stop  
Stopping nginx:                                            [  OK  ]
[root@vm5808 ~]# /etc/init.d/nginx start
Starting nginx:                                            [  OK  ]

error has gone:

[root@vm5808 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

I've tried restart before stop and start, but Nginx wouldn't restart:

[root@vm5808 ~]# /etc/init.d/nginx restart
nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
nginx: configuration file /etc/nginx/nginx.conf test failed

Upvotes: 6

PerroVerd
PerroVerd

Reputation: 955

Check all the virtualhosts in apache, probably one of them is listening on port 80

Upvotes: 0

Mohammad AbuShady
Mohammad AbuShady

Reputation: 42879

Your problem is simple, you seem to have both nginx and apache listening on port 80, so nginx finds the port already in use, you need to move apache to another port, like 81 for example, and make nginx listen on 80, because it's the one which is going to receive the http requests and proxy it.

Upvotes: 2

Related Questions