V
V
vstas2014-05-06 11:54:04
Nginx
vstas, 2014-05-06 11:54:04

Has anyone encountered the problem of restarting nginx?

Sometimes the system fails to restart nginx. The most annoying thing about all this is "sometimes".
Currently installed on the server:

Debian GNU/Linux 7 (wheezy)
 nginx/1.2.1  (пакет nginx-extras [nginx web/proxy server (extended version)])

When restarting by mistake, the following appears in the logs.
2014/05/06 07:03:04 [emerg] 3176#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2014/05/06 07:03:04 [emerg] 3176#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2014/05/06 07:03:04 [emerg] 3176#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2014/05/06 07:03:04 [emerg] 3176#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2014/05/06 07:03:04 [emerg] 3176#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2014/05/06 07:03:04 [emerg] 3176#0: still could not bind()

When analyzing the situation, it was revealed that nginx itself continues to listen to this port and there is a feeling that it is not going to let it go. After kill everything starts successfully.
On the Internet, they mainly write that the problem may be as follows:
1) A setting has been added to the server by default
listen [::]:80 default_server;
and it creates a problem associated with IP6.
But even the nature of the error in the logs is slightly different.
2) Running Apache and its conflict with nginx
We don't have this problem.
[email protected]:/etc# netstat -tnlp | grep 80 
tcp        0      0 0.0.0.0:80          0.0.0.0:*               LISTEN      10307/nginx      
tcp        0      0 127.0.0.1:8080      0.0.0.0:*               LISTEN      11605/apache2

3) It's just that the process is frozen, you can kill it and restart everything.
This certainly suits our option, but it does not suit us at all.
My guess is that the problem could be:
- my nginx settings are crooked
- debian startup/restart scripts are incorrect
- problematic nginx build in debian
Has anyone experienced a similar manifestation of nginx?
I am very worried that this error is not a system error, but I need to automatically restart nginx.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vlad Zhivotnev, 2014-05-06
@vstas

Tags: start-stop-daemon, shit.
We solved this problem by adding kill -9 at the end of the nginx init script, if it does not die in a few seconds.
start-stop-daemon returns that everything is OK, but in reality, nginx has not yet closed all connections (and has not killed processes).

A
Alexey Sundukov, 2014-05-06
@alekciy

incorrect debian startup/restart scripts

The init script sometimes reports that the server has been stopped. In fact, this is not so. If after that you try to run it again through init, then the script thinks that the service is not working and starts it again, resting on the bind error. As far as I remember, the problem occurs when an incorrect process PID is written to the runtime file. Those. the problem can be solved by simply rewriting the init script.

I
Igor, 2014-05-06
@merryjane

Try to install the latest version from the Nginx repositories directly.

V
Vadim Yakovlev, 2014-05-06
@FrimInc

look in /etc/init.d/nginx where he puts nginx.pid, if he has rights to this location, and if the file appears there after launch.
Because when the process stops, it takes from this file, if the file does not exist, it reports that everything is stopped.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question