configure nrpe(nagios) to listen on different port

Purpose : Some times Isp Or vps provider they block port 5666 Or for any reason if you want to configure nrpe to listen different port example 15666, follow as bellow:

On the Remote host(linux-vps) :

1. Change the Port number in : /etc/xinetd.d/nrpe

# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
        flags           = REUSE
        socket_type     = stream
       port            = 15666
        wait            = no
        user            = nagios
        group           = nagios
        server          = /usr/local/nagios/bin/nrpe
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = no
        only_from       = ip.of.nagios.server

2. Change port number : vi /etc/services

nrpe            15666/tcp                        # NRPE

3. Change port number in : /usr/local/nagios/etc/nrpe.cfg


4 . Restart nrpe daemon : service xinetd restart

On the server(nagiosserver) :
Purpose : Example, I have more then 10 linux server. 9 of them listen port 5666 , but only one of them listen port 15666 . So I need to create a different set of commands for nagios server to connect that nrpe client on different port.

1. Create a command in command.cgi file ( /usr/local/nagios/etc/objects/commands.cgi)

#This is slightly modified from check_nrpe command
#Because Vps company they blocked port 5666
#So i had to configure linuxvps server to listen on port  15666, So
#I need to create a different command to connect to different port
define command{
command_name check_nrpe_vps
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 15666 -c $ARG1$

2. Now call this check_nrpe_vps commands from host definition file
Example : host definition file for linuxvps is : linuxvps.cgi ( /usr/local/nagios/etc/objects/linuxvps.cgi)

   define service{
   use generic-service
   host_name linuxvps
   service_description CPU Load
  check_command check_nrpe_vps!check_load

3. now Call this linuxvps.cgi from nagios.cfg file


4. restart the nagios.
So now this nagios server will connect to nrpe client via 15666 port.


5 Responses to “configure nrpe(nagios) to listen on different port”

  1. michal says:


    Thanks for Yours HOW TO, but I have one suggestion. We don’t have to configure server xinetd with nrpe. We only need to change option “server_port” in nrpe.cfg file and it is all.

    I had many situation that I had to change standard nrpe port and it’s worked.

  2. Fosiul says:

    β€˜@michal β€˜

    Hi Michal
    Yes you are true, we don’t have to use Xinetd for nrpe.
    but its an options to secure the nrpe daemon from outsider i.e Daniel server of attack
    why xinetd :
    ref :


  3. Heang says:

    Hi Fosiul,

    if I want to run nrpe in multiple ports How can I do that.

    I have nrpe running in default port: 5666 with Nagios1. and I have another nagios (nagios2) I want it to check with port 5667.

    Nagios1(5666) and Nagios2(5667) check Remote host both (5666,5667)

  4. Fosiul says:

    Hi Gratha,

    Just to clarify :
    You have 2 individual Nagios servers ( nagios-1 and nagios-2)
    and you want to monitor some services in a host call “server1” .

    So nagios-1 will perform some nrpe base service check on server1
    also nagios-2 will perform some nrpe base service check on server1

    if my understanding is appropriate , then you don’t need to worry about configuring nrpe on different port.

    in nrpe.cfg file (server1) , you can allow both nagios-1 and nagios-2 to perform service check


    also , if you have configured one nagios server for 2 nagios instances (5666,5667) , still you can use one nrpe daemon to access the host (server1) by using bellow


    Bottom line is : one nrpe daemon can handle request from multiple Nagios sevrer, example I have more then 20 nagios server but I have only one nrpe daemon running on each host.

    hope this will help you to understand .

    Please let me know if there is any confusion.

  5. Heang says:

    Hi Fosiul,
    Thank for your clear explain, I will try … πŸ™‚

Leave a Reply