Is your monitoring server showing the NRPE port 5666 connection refused error?
Nagios monitoring system shows Connection refused error when the server does not listen to 5666 port or if there is any firewall block.
At Bobcares, we regularly fix NRPE errors for our customers as part of our Server Management Services.
Today, let’s get into the details on how our Support Engineers fix this NRPE port 5666 Connection refused error.
Why do we see ‘NRPE port 5666 Connection refused’ error?
By default, Nagios Remote Plugin Executor aka NRPE uses port 5666 for its checks.
Therefore, the connection refused error displays if the NRPE traffic is not traversing a firewall, or if port 5666 of the server is not open.
Nagios works on a server-client relationship. Again, both the Nagios server and Nagios client have to be on the same network and should be able to listen to port 5666.
For instance, when there are problems with port 5666 connection, it appears as,
How we fix NRPE port 5666 connection
At Bobcares, where we have more than a decade of expertise in managing servers, we see many customers face problems with ‘NRPE error 5666’.
Now, let’s see how our Support Engineers fix this error either by opening port 5666 in firewall or editing NRPE config.
1. Opening port 5666
Frequently, in the Nagios server panel, we could trace that the ‘NRPE error 5666’ as a critical error while monitoring different servers. The error is one of the common problems faced while we monitor the server.
Here, we assist the customer and fix the error by opening port 5666 in the firewall.
The modification of the firewall depends on the type of server and the firewall in use. Let’s now explore the major ones.
a) Allow port 5666 in IPTables
A major share of servers uses IPTables as their firewall. Initially, we check whether the port 5666 is listening or not by the following command.
netstat -l | grep 5666
If the port is found open, the prompt result with listening and it appears as following in the prompt.
We then assist the customer to open the port 5666 and resolves the problem.
Hence, to open the port, we add an IPTables rule for the port. For this, we edit the IPTables file as shown below:
vi /etc/sysconfig/iptables
In the configuration file, we add the following line to open the port 5666.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT
Thereafter we restart the IPTables service using the following command:
service iptables restart
Finally, we save the file and restart the NRPE service.
service nrpe restart
b) Whitelisting port in FirewallD
In addition, for CentOS servers, we whitelist the port 5666 in FirewallD. We use the following command to whitelist the 5666 port.
firewall-cmd --zone=public --add-port=5666/tcp
firewall-cmd --zone=public --add-port=5666/tcp --permanent
That resolves the NRPE error.
c) Open port in Ubuntu with UFW
On servers with Ubuntu’s Uncomplicated Firewall, we open the connections on port 5666 on the monitored servers.
Here, we make sure to allows the connections only from the Nagios IP address.
ufw allow proto tcp from <Nagios IP> to any port 5666
Finally, we restart the NRPE module:
/etc/init.d/nagios-nrpe-server start
That fixes the NRPE port 5666 Connection refused error.
2. Modifying NRPE configuration
Similarly, Nagios port 5666 errors can creep in due to incorrect NRPE configuration too.
In servers that report the 5666 connection refused error, we check the value of server_address in the /etc/nagios/nrpe.cfg file. We correctly add the address that nrpe should bind to.
A common mistake in the NRPE config file relates to the improperly configured “allowed_hosts” directives. This has an effect only when NRPE runs as a standalone daemon. Therefore, we correct it by adding the server IP address.
allowed_hosts=127.0.0.1,x.x.x.x
Here, x.x.x.x is the server’s IP address.
That fixes the problem and makes NRPE working again.
[Need any further assistance with ‘NRPE port 5666 Connection refused’ error? – We can help you with it]
Conclusion
In short, the NRPE error 5666 connection refused error mostly occurs due to the NRPE port 5666 restrictions in firewall or an incorrect NRPE config. Today, we saw how our Support Engineers help our customers to fix this error.
0 Comments