NSClient++ returning "Connection refused" error

Ok so I have recently configured a new Nagios 3.0.3 box sitting on the latest Debian version. I have been able to get everything more or less working flawlessly except for one single remote machine. I have checked and triple checked that the same basic settings used on the other remote machines are the same on this… Nsclient service is running and i have verified that the .ini file that configures the service is set to allow the correct host addresses, port and log retention.

From the nagios box itself I have verified that I am able to nmap the remote machine on port 1248 and well as run the virtual check command test “./check_nt -H serverip -p 1248 -v CPULOAD -l 10,80,95,60,80,95,1440,80,95”. However, within the web interface all of the checks using the check_nt command are failing with “Connection refused” even though with the same settings and command format are working without fault.

On a side note I have verified that the remote machine is not be hind a switch, firewall, load balancer that could potentially block anything.

The following are my check commands…

‘Check_nt_cpuload’ command definition

define command{
command_name check_nt_cpuload
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 1248 -v CPULOAD -l $ARG1$
}

define service{
use generic-service ; Name of servi$
host_name prowebap03
service_description CPULoad
check_command check_nt_cpuload!10,80,95,60,80,95,1440,80,95!
}

Did you ever get this fixed? We’re having the same problem…

Did you check the nsclient.log file on the server that you are trying to monitor? It may tell what is wrong.

I am also getting this problem now. A check_nt test run from the commandline to the remote windows xp host running NSClient++ is successful but the nagios web interface just returns “Connection Refused”.

I have included my nsclient.log but I can’t see anything that gives any indication of what the problem is. The checkuptime was run from the commandline.

2009-01-08 13:51:19: message:.\FileLogger.cpp:92: Starting to log for: NSClient++ - 0.3.5.2 2008-09-24 2009-01-08 13:51:20: message:CACHE.\NSClient++.cpp:370: Attempting to start NSCLient++ - 0.3.5.2 2008-09-24 2009-01-08 13:51:20: debug:CACHE.\NSClient++.cpp:773: Loading plugin: CheckDisk... 2009-01-08 13:51:20: debug:CACHE.\NSClient++.cpp:773: Loading plugin: Event log Checker.... 2009-01-08 13:51:20: debug:CACHE.\NSClient++.cpp:773: Loading plugin: Helper function... 2009-01-08 13:51:20: debug:CACHE.\NSClient++.cpp:773: Loading plugin: CheckSystem... 2009-01-08 13:51:20: debug:CACHE.\PDHCollector.cpp:66: Autodetected w2k or later, using w2k PDH counters. 2009-01-08 13:51:20: debug:CACHE.\PDHCollector.cpp:103: Using index to retrive counternames 2009-01-08 13:51:20: debug:CACHE.\NSClient++.cpp:773: Loading plugin: File logger... 2009-01-08 13:51:20: message:CACHE.\FileLogger.cpp:93: Log path is: C:\users\tonyp\work\NSClient++\\nsclient.log 2009-01-08 13:51:20: debug:CACHE.\NSClient++.cpp:773: Loading plugin: NRPE server... 2009-01-08 13:51:20: debug:CACHE.\PDHCollector.cpp:123: Found countername: CPU: \Processor(_total)\% Processor Time 2009-01-08 13:51:20: debug:CACHE.\PDHCollector.cpp:124: Found countername: UPTIME: \System\System Up Time 2009-01-08 13:51:20: debug:CACHE.\PDHCollector.cpp:125: Found countername: MCL: \Memory\Commit Limit 2009-01-08 13:51:20: debug:CACHE.\PDHCollector.cpp:126: Found countername: MCB: \Memory\Committed Bytes 2009-01-08 13:51:20: debug:CACHE.\NSClient++.cpp:773: Loading plugin: NSClient server... 2009-01-08 13:51:20: debug:CACHE.\NSClient++.cpp:773: Loading plugin: SystemTray... 2009-01-08 13:51:20: message:.\NSClient++.cpp:476: NSCLient++ - 0.3.5.2 2008-09-24 Started! 2009-01-08 13:51:20: debug:.\TrayIcon.cpp:53: Failed to load: ChangeWindowMessageFilter aparently we are not on Vista... 2009-01-08 13:51:20: debug:d:\documents\Visual Studio 2005\Projects\NSCP\branches\stable\include\Socket.h:637: Bound to: 0.0.0.0:12489 2009-01-08 13:51:20: debug:d:\documents\Visual Studio 2005\Projects\NSCP\branches\stable\include\Socket.h:637: Bound to: 0.0.0.0:5666 2009-01-08 13:51:37: debug:.\NSClientListener.cpp:146: Data: None&3 2009-01-08 13:51:37: debug:.\NSClientListener.cpp:171: Data: 2009-01-08 13:51:37: debug:.\NSClient++.cpp:910: Injecting: checkUpTime: nsclient 2009-01-08 13:51:37: debug:.\NSClient++.cpp:946: Injected Result: OK '281485' 2009-01-08 13:51:37: debug:.\NSClient++.cpp:947: Injected Performance Result: ''

Cheers
Tony

The problem is that your server is trying to connect to the client on port 1248 and your client is listening on port 12489. You have one of two options:

  1. Change the check_nt command on your server from ‘-p 1248’ to ‘-p 12489’

  2. Change your client to listen on port 1248 by editing the local configuration file

I had this same problem and I wasn’t specify a port on my check_nt commands and I found that the default port is 1248 and the default for nsclient++ is 12489 so it will not work. One I changed my server commands everything works perfectly and no more connection refused.

Hello
I have this error as well. The thing is I have several Windows hosts all with the very same nsc.ini file and only one is getting the “Connection refused” error on the Nagios Web Interface. To make things even more confusing this host used to work and nothing has changed on the host. The only thing that changed was the Nagios Server. My Nagios Server had a catastrophie and I had to rebuild from scratch, I did however use all the original host config files from backup. Any ideas anyone?

I found my Problem:
It was due to a DNS Problem.

Connection is refused because nsclient doesn’t listen on port 1248.
nsclient++ doesn’t use by default port 1248. Correct test check command is:
"./check_nt -H serverip -p 12489 -v CPULOAD -l 10,80,95,60,80,95,1440,80,95".
Second possibility is to change default value in .ini file:
;# NSCLIENT PORT NUMBER
; This is the port the NSClientListener.dll will listen to.
port=12489

So I ran across this error as well, after 1 week of beating my head against the wall (ie google and reading all these posts) I decided to simply uninstall nsclient++ and reboot my server & then re-install nsclient++ I was able to get it to talk to the nagios server. I am not sure this will work for everyone but it did for me.