# BIND9 Can't stop service correctly

## ianneub

Hello all,

I've just emerge'd net-dns/bind-9.2.2 and ran the script to put it in a chroot'ed envirnment. I can't seem to stop the server cleanly.

Here is what I did:

```
emerge bind

ebuild /var/db/pkg/net-dns/bind-9.2.2/bind-9.2.2.ebuild config

echo "alias rndc='rndc -k /chroot/dns/etc/bind/rndc.key'" > /root/.bashrc # I had no /root/.bashrc

source /root/.bashrc

/etc/init.d/named start

/etc/init.d/named stop

 * Stopping named...                                                      [ !! ]
```

The default /etc/init.d/named script is looking for the pid file in the wrong place.

```
if [ $CHROOT -a -d $CHROOT ] ; then

      PIDFILE="${CHROOT}/var/run/named.pid"

      KEY="${CHROOT}/etc/bind/rndc.key"

   else

      PIDFILE="/var/run/named.pid"

      KEY="/etc/bind/rndc.key"

fi
```

The line "PIDFILE="${CHROOT}/var/run/named.pid"" should read "PIDFILE="${CHROOT}/var/run/named/named.pid"" according to the default /etc/bind/named.conf.

----------

## jsleeper

I had the same situation, and this suggestion made it work correctly.

Thanks ianneub!!!

----------

## eagle_cz

lol i got same problem 

named by default save pid to /var/run/named.pid

bun when i try to stop named, he is looking for /var/run/named/named.pid

Soution is to edit /etc/init.d/named a put /var/run/named.pid instead of $PIDFILE in stop section

i tested it on 2 machines... both had this problem

no im only wondering whi is he starting named as root, while there is ............... /usr/sbin/named -u named 

chmmm ...any tips ?

----------

## Sven Vermeulen

A better solution is to not touch /etc/init.d/named but edit /etc/named.conf in which you can define pid-file.

----------

## To

 *Sven Vermeulen wrote:*   

> A better solution is to not touch /etc/init.d/named but edit /etc/named.conf in which you can define pid-file.

 

Well that's what I did but it's /etc/bind/named.conf but I think everybody understood what you mean  :Very Happy: 

Tó

----------

## ianneub

 *Sven Vermeulen wrote:*   

> A better solution is to not touch /etc/init.d/named but edit /etc/named.conf in which you can define pid-file.

 Good call, but shouldn't the ebuild handle chroot properly?

----------

