Resolving Nagios Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’ for update!

Cannot Run Nagios Service Commands – Could not open command file Error

After installing Nagios, everything may appear to be up and running just fine until

Nagios Service Commands

Nagios Service Commands

you attempt to run a service command such as “Re-schedule the next check of this service”.


As soon as you get through the next page and hit the commit button, you get this nasty gram message from nagios saying that you cannot run nagios/var/rw/nagios.cmd:

Error:  Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’ for update!

The permissions on the external command file and/or directory may be incorrect.  Read the FAQs on how to setup proper permissions.

An error occurred while attempting to commit your command for processing

Return from whence you came

As shown in the screenshot image below…

Nagios: Permissions on the external command file and/or directory may be incorrect

Nagios Error: Could not open Command file for update

Grr!  Nothing could be more aggravating then getting this error because your getting it when you actually have a real error on one of your servers that you need to work with and this becomes a distraction from resolving the real problem anyway.

What this Nagios Error is About

So, if we dissect this error, what it is saying is that somehow we don’t have permissions to run the /usr/local/nagios/var/rw/nagios.cmd file.  So, our first reaction is to check the permission on the file:

$ ls -l
total 0
prw-rw—- 1 nagios nagios 0 Nov 20 10:01 nagios.cmd

So, at this point, we are all tempted to just change the permissions on the cmd file, which will indeed resolve the problem until the nagios service is restarted again.  Restarting will set the permissions to their original state again.  So what we need is a real solution to the problem.  So, the question goes to who or which user doesn’t have permissions.  It looks like the nagios user does, isn’t that what nagios is running as.  Nope!  It is the webserver that is attempting to run the command and not the nagios service.  So, the user that is running your webserver needs to have permissions to run this command file.

The Solution

The solution is to add the userid that is running your webserver to the nagios group.  In my case, I am using Apache httpd which is running using the apache userid.  So, I need to add the apache user to the nagios group.

# usermod -G nagios apache

Now, we verify that the apache user is part of the nagios group:

# grep nagios /etc/group


Now that is done, we need to restart the Apache service so that it can pick up the change in group membership.

# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                             [  OK  ]

Problem Resolved!

With all of this done, try the nagios service command again, it should now be working.



The following two tabs change content below.
Jeff has 20 years of professional IT experience, having done nearly everything in his roles of IT consultant, Systems Integrator, Systems Engineer, CNOC Engineer, Systems Administrator, Network Systems Administrator, and IT Director. If there is one thing he knows for sure, it is that there is always a simple answer to every IT problem and that downtime begins with complexity. Seasoned IT professional by day, Jeff hopes to help other IT professionals by blogging about his experiences at night on his blog: You can find Jeff on or LinkedIn at: LinkedIn or Twitter at: Twitter

Latest posts by Jeff Staten (see all)

6 comments for “Resolving Nagios Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’ for update!

  1. Ian
    June 26, 2014 at 4:30 pm


    usermod -a -G nagcmd apache

    Works for the version of Nagios and CentOS I have



  2. Celeste
    July 25, 2014 at 11:20 am

    Worked for me. Awesome. Thanks!

  3. Pepi
    August 13, 2014 at 8:12 am

    also for me:

    usermod -a -G nagcmd apache

  4. September 2, 2014 at 2:13 am

    Hi, your solutions works fine for me on Centos 6.5:
    # usermod -G nagcmd apache

  5. Frank
    September 23, 2014 at 6:54 am

    Thanks for this tip. helped me with nagios 4 on debian wheezy

  6. Roberto
    October 16, 2014 at 7:56 am

    I had that change the group, because I use Ubuntu

    # usermod -G nagios www-data
    # usermod -G nagcmd www-data


Leave a Reply

Your email address will not be published. Required fields are marked *