connect to address 127.0.0.1 and port 0: Connection refused

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Post Reply
pnikhade
Posts: 4
Joined: Thu Jul 27, 2023 10:23 am

connect to address 127.0.0.1 and port 0: Connection refused

Post by pnikhade »

Hi All,

Greetings of the day !

I have one RHEL EC2 instance running nginx listening to port 80. I have defined commands and service check in host config file to monitor this host.
After running below command manually, I could see it's working perfectly.

./check_tcp -H 13.233.117.236 -p 80 -w 10 -c 20
TCP OK - 0.001 second response time on 13.233.117.236 port 80|time=0.001162s;10.000000;20.000000;0.000000;10.000000

But on GUI it shows an error like below, i tried to see port 80 is open in firewall so what can be reason here ?

connect to address 127.0.0.1 and port 0: Connection refused.

Below command already defined in commands.cfg,

define command {
command_name check_tcp
command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$
}

On host nrpe.cfg, defined below command,

command[check_tcp]=/usr/local/nagios/libexec/check_tcp -w 10 -c 20

Thanks,
Piyush Nikhade.
kg2857
Posts: 249
Joined: Wed Apr 12, 2023 5:48 pm

Re: connect to address 127.0.0.1 and port 0: Connection refused

Post by kg2857 »

Try adding $ARG1$ to the command.
command[check_tcp]=/usr/local/nagios/libexec/check_tcp -w 10 -c 20 $ARG1$
pnikhade
Posts: 4
Joined: Thu Jul 27, 2023 10:23 am

Re: connect to address 127.0.0.1 and port 0: Connection refused

Post by pnikhade »

Thanks for your response, but it shows status as "Unknown" after modifying the nrpe.cfg on client.

Complete alert as below, looks like that is incorrect syntax.

Current Status: UNKNOWN (for 0d 0h 2m 22s)
Status Information: Usage:
check_tcp -H host -p port [-w <warning time>] [-c <critical time>] [-s <send string>]
[-e <expect string>] [-q <quit string>][-m <maximum bytes>] [-d <delay>]
[-t <timeout seconds>] [-r <refuse state>] [-M <mismatch state>] [-v] [-4
Performance Data: -6] [-j] [-D <warn days cert expire>[,<crit days cert expire>]] [-S <use SSL>] [-E] [-N <server name indication>]
Current Attempt: 3/3 (HARD state)
Last Check Time: 04-29-2024 11:28:46
kg2857
Posts: 249
Joined: Wed Apr 12, 2023 5:48 pm

Re: connect to address 127.0.0.1 and port 0: Connection refused

Post by kg2857 »

Looks like the plugin wants args in some order. This from the short help output I read...
command[check_tcp]=/usr/local/nagios/libexec/check_tcp $ARG1$ -w 10 -c 20
Post Reply