# Nginx not removing stream socket

**URL:** <https://www.ruby-forum.com/t/nginx-not-removing-stream-socket/244892>\
**Category:** NGINX\
**Created:** [July 4, 2016, 3:36pm UTC](https://www.ruby-forum.com/t/nginx-not-removing-stream-socket/244892 "2016-07-04T15:36:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [July 4, 2016, 3:36pm UTC](https://www.ruby-forum.com/t/nginx-not-removing-stream-socket/244892/1 "2016-07-04T15:36:34Z")

</div>

Hi,

On CentOS7 . nginx is not removing the stream socket on shutdown  
causing restarts to fail unless the socket file is manually removed.  
nginx process itself exit .But becase of the file not being removed  
nginx is unable to bind to the socket file on next start

systemd unit file  
#######################

[Service]  
Type=forking  
PIDFile=/var/run/nginx.pid  
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf  
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf  
ExecReload=/bin/kill -s HUP $MAINPID  
ExecStop=/bin/kill -s QUIT $MAINPID  
PrivateTmp=true

[Install]  
WantedBy=multi-user.target  
###########################

#nginx configuration

stream {  
upstream mysql\_backend {  
server unix:/var/lib/mysql/mysql\_original.sock;  
server x.x.x.x:13306 backup;  
}

```
server {
    listen 127.0.0.1:3306;
    listen unix:/var/lib/mysql/mysql.sock;
    proxy_pass mysql_backend;
}

```

}  
######################################

The same setting is working fine on a centos6 server with init .

which use the killproc function from /etc/rc.d/init.d/functions

Even on CentOS6 …if I do

kill -QUIT \<nginx\_pid\>

the binary exits without removing the socket.

What am I doing wrong?.

What is the correct signal to terminate the process and remove the  
sockets bound.

## Thanks,

Anoop P Alias

---

<div class="post-metadata">

**Author:** ![Anoop\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a183cd/32.png) [@Anoop\_A](https://www.ruby-forum.com/u/Anoop_A)\
**Post date:** [July 4, 2016, 3:53pm UTC](https://www.ruby-forum.com/t/nginx-not-removing-stream-socket/244892/2 "2016-07-04T15:53:31Z")

</div>

ok just found this - [#753 (Nginx leaves UNIX domain sockets after SIGQUIT) – nginx](https://trac.nginx.org/nginx/ticket/753)

So shall i use SIGTERM instead of SIGQUIT in the systemd unit file?

On Mon, Jul 4, 2016 at 7:05 PM, Anoop A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## [Service] ########################### listen 127.0.0.1:3306; Even on CentOS6 ..if I do Thanks,
> 
> Anoop P Alias

–  
Anoop P Alias
