Nagios NRPE Connection Error — Quick Fix
In this tutorial, you'll learn about Nagios NRPE Connection Error. We cover key concepts, practical examples, and best practices.
The Problem
Nagios cannot execute checks via NRPE on a remote host. The Nagios server shows "NRPE: Unable to read output" or "Connection refused by host." Remote checks return "CHECK_NRPE: Socket timeout after 10 seconds."
Error example:
CHECK_NRPE: Error - Could not connect to 192.168.1.100:5666
NRPE: Unable to read output
Connection refused by host
The Fix
Step 1: Check the NRPE daemon on the remote host
WRONG — modifying the Nagios server config without checking the remote host:
# The problem is almost always on the remote host
RIGHT — check NRPE status on the remote host:
systemctl status nagios-nrpe-server
Output:
nagios-nrpe-server.service - Nagios Remote Plugin Executor
Loaded: loaded
Active: inactive (dead)
Start and enable it:
systemctl enable --now nagios-nrpe-server
Step 2: Verify allowed_hosts and firewall
WRONG — allowing all hosts in nrpe.cfg:
# allowed_hosts=0.0.0.0/0 is a security risk
RIGHT — add the Nagios server's IP to allowed_hosts:
grep allowed_hosts /etc/nagios/nrpe.cfg
Output:
allowed_hosts=127.0.0.1,192.168.1.50
Ensure the firewall allows port 5666:
firewall-cmd --add-port=5666/tcp --permanent
firewall-cmd --reload
Use DodaTech's NRPE Connection Tester to validate NRPE configurations, test command execution, and diagnose timeout issues from a single interface.
Prevention Tips
- Use the same NRPE version on all monitored hosts
- Restrict allowed_hosts to your Nagios server's IP only
- Configure firewall rules for port 5666, not SELinux-only exceptions
- Test NRPE commands locally on the remote host before deploying
- Use DodaTech's Nagios Fleet Manager for centralized NRPE configuration
Common Mistakes with nrpe connect
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
- Misunderstanding that
Stringis[Char]with poor performance for large text operations - Using
foldlinstead offoldl'causing stack overflow on large lists
These mistakes appear frequently in real-world NAGIOS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Related: DodaTech's Nagios Migration Toolkit provides automated NRPE configuration, testing, and deployment for large-scale monitoring rollouts.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro