# Restarting Services



## leveraction (Jun 9, 2017)

OK, I know this is very simple, or at least it should be, so apologies.  I am running bind DNS.  I made a change to the config file and now want to restart/reload the service.  There is a script called 'named' in /usr/local/etc/rc.d.  

I tried 
`service named restart` and `service named stop` and it replies:
"named not running? (check /var/run/named/pid)."

What am I missing here?


----------



## SirDice (Jun 9, 2017)

A restart implies there's a running instance that needs to be stopped first. Stop also stops a service. You're trying to restart or stop a service that isn't running.


----------



## leveraction (Jun 9, 2017)

When I type `service -e` one of the things listed is "/usr/local/etc/rc.d/named".  So this does not mean that it is running then?


----------



## tobik@ (Jun 9, 2017)

That just means that it is enabled in /etc/rc.conf.


----------



## leveraction (Jun 9, 2017)

I type `service named status` and get "named is running as pid 624."  Surely this means it is running?


----------



## Eric A. Borisch (Jun 9, 2017)

Immediately after _status_ states it running, does _stop_ still fail?


----------



## leveraction (Jun 9, 2017)

Here is a cut and paste directly from my terminal:  (the pid changed because I power cycled a little while ago)

# `service named status`
named is running as pid 601.
# `service named stop`
named not running? (check /var/run/named/pid).
#


----------



## Datapanic (Jun 9, 2017)

I think it's a bug in /usr/local/etc/rc.d/named.  This section:

```
find_pidfile()
{
        if get_pidfile_from_conf pid-file ${named_conf}; then
                pidfile="${_pidfile_from_conf}"
        else
                pidfile="/var/run/named/pid"
        fi
}
```

is wrong.

the line `pidfile="/var/run/named/pid"` should be `pidfile="/var/run/named/named.pid"` and then `service named status|restart|stop` will actually find the pid value and not return the OP's error, which I duplicated on my stuff.

To answer the question - use `rndc reload` to reload the config and/or zone changes.

Edit to add: the pid file location can also be specified in the named.conf


----------



## leveraction (Jun 9, 2017)

Thanks!  I will try this on my machine.  I am glad to see that I am not crazy!


----------



## SirDice (Jun 10, 2017)

Which BIND version? I have dns/bind99 and that stops/restarts correctly. 


```
root@maelcum:~ # service named restart
Stopping named.
Waiting for PIDS: 2237.
./var/dump missing (created)
./var/stats missing (created)
Starting named.
root@maelcum:~ #
root@maelcum:~ # service named stop
Stopping named.
Waiting for PIDS: 58982.
root@maelcum:~ # ps -ax | grep named
59006  0  S+       0:00.00 grep named
root@maelcum:~ # service named start
Starting named.
root@maelcum:~ # ps -ax | grep name
59093  -  Ss       0:00.29 /usr/local/sbin/named -t /var/named -u bind -c /usr/local/etc/namedb/named.conf
59096  0  S+       0:00.00 grep name
```


----------



## Datapanic (Jun 10, 2017)

dns/bind910 and dns/bind911 both have the typo in /usr/local/etc/rc.d/named


----------



## trev (Jun 12, 2017)

Datapanic said:


> dns/bind910 and dns/bind911 both have the typo in /usr/local/etc/rc.d/named



I'm not so sure there's a typo... I'm running bind911 and my /usr/local/etc/rc.d/named works to start and stop the service. Looking at /usr/local/etc/namedb/named.conf and /usr/local/etc/namedb/named.conf.sample shows the pid file set as:

`pid-file        "/var/run/named/pid";`

which explains why my setup works. Perhaps the OP has changed something or is using an old named.conf.


----------



## leveraction (Jun 12, 2017)

Datapanic:  OK, I tried your change and it worked.  The server I am running is freshly installed FreeBSD and everything on it was also just installed.  From the top of the /usr/local/etc/rc.d/named file I cut and paste the following that I think gives some clue as to the version I am using:
"# $FreeBSD: tags/RELEASE_11_0_0/dns/bind99/files/named.in 395660 2015-08-31 10:06:27Z mat $"
If this is not informative, I will post whatever is required if someone will point me in the ri


----------

