XINETD/NRPE | Cannot Write to Pidfile

 Cannot write to pidfile ‘/var/run/nagios/’ – check your privileges.

This error occurs when the “pidfile” cannot be rewritten. In most cases, this happens after a reboot and the file itself is read-only instead of read/write.

If that is the case, go ahead and restart the xinetd and nrpe services.

service xinetd restart
service nrpe restart

Next, check the status of xinetd and nrpe

servie xinetd status
service nrpe status

Your xinet daemon should stay active and show that it’s running. When you check NRPE, it will say failed and display the following.

 nrpe[1312]: Starting up daemon
 nrpe[1312]: Cannot write to pidfile '/var/run/nagios/' - check your privileges.

To fix this, you will need to go to /var/run/ if you are using xinetd with nrpe.

check the permissions of the tile with ll or ls -l

-r--r----- 1 nagios nagios 6 Dec 4 10:12

In the output above, the file has only read access and cannot be written too. To fix this issue, first, change the ownership to nagios and then changed the permissions.

chown nagios:nagios /var/run/

Next, change the permissions to Read, Write, No Execute

chmod 660

Once done, check the file with ll  -rw-rw—- 1 nagios nagios 6 Dec 4 10:16 Restart the service

service nrpe restart

Check the status to see if the service is running.

service nrpe status


If the service still doesn’t work after that, you will need to locate the nrpe.cfg file and edit it.  Mine is located here /usr/local/nagios/etc/nrpe.cfg. Look for the following section and edit the section in red.

# The name of the file in which the NRPE daemon should write it's process ID
# number. The file is only written if the NRPE daemon is started by the root
# user and is running in standalone mode.


In some cases, you will need to change it to xinetd if you have installed that. If you are just using nrpe, then you can leave that alone.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s