DB / Linux / N/A
WARNING
Linux Connection Refused
The 'Connection Refused' error (often associated with errno 111, ECONNREFUSED) indicates that a TCP connection request was actively rejected by the remote host's kernel. This typically means nothing is listening on the specified IP address and port.
Common Causes
- The target service (e.g., SSH, web server) is not running on the remote host.
- The service is bound to a different IP address (like 127.0.0.1) instead of the network interface you are trying to reach.
- A host-based firewall (iptables, firewalld, ufw) is blocking the connection to the specific port.
How to Fix
1 Check Service Status and Port Binding
Verify the target service is running and listening on the correct network interface and port.
BASH
$ # Check if a service like sshd is running
sudo systemctl status sshd
# Use netstat or ss to see listening ports
sudo ss -tlnp | grep :22
# Or
sudo netstat -tlnp | grep :22 2 Inspect and Configure Host Firewall
Check if a local firewall is blocking the port and add a rule to allow traffic if necessary.
BASH
$ # For firewalld (RHEL/CentOS/Fedora)
sudo firewall-cmd --list-all
sudo firewall-cmd --add-service=ssh --permanent
sudo firewall-cmd --reload
# For ufw (Ubuntu/Debian)
sudo ufw status
sudo ufw allow ssh
sudo ufw reload 3 Test Connectivity and Service Configuration
Use telnet or nc from the client to test the basic TCP connection and review the service's configuration file.
BASH
$ # Test if the port is reachable (replace IP and port)
nc -zv 192.168.1.10 22
# Check the service config file (e.g., SSH)
sudo cat /etc/ssh/sshd_config | grep -E '^ListenAddress|^Port'