You may encounter issues with connecting to a remote host such as or another service site with an error stating the connection was refused. This is often caused by a firewall or block at the network level. You can use a few tools to troubleshoot the connection and determine if the remote host is blocking this or your local server. 


Using host, we can first determine the IP address and if our DNS lookup is working. 

host has address has address

Once we have the IP address of the domain we’re trying to connect to, use telnet or curl to check the connection. 

$ curl
<title>302 Found</title>
<p>The document has moved <a href="">here</a>.</p>
$ telnet port_number
Connected to
Escape character is '^]'.

If you are unable to connect using curl or telnet, next, use MTR and see where the connection stops. You may need to install this.

yum install mtr
# mtr -rc 10
Start: Thu Jun 25 16:10:24 2020

If there is no result, then we know this is being blocked at the server. If this does provide an output, this will help determine where the connection is dropping, weather it’s the hosting provider or at the remote location you’re trying to access.

In the event you do not get an output, and you have CSF, you can use the following to search and verify if it is blocked.

 csf -g <IP>

If you have iptables, you can use the following:

iptables -L INPUT -v -n | grep <ip>
iptables -vL -t nat|grep <IP>

If the IP is listed, you can use one of the following to whitelist the IP for CSF or for Iptables. Using -D will delete the rule. You may need to modify this depending on the rule in Iptables.

csf -a 
iptables -D INPUT -s -j DROP

Finally, make sure you save the firewall:

service iptables save

Originally posted on January 26, 2022 @ 1:08 pm

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.