connection refused errors are generated during a
connect system call when an application attempts to connect using TCP to a server port which is not open.
The two most common causes of this are:
It is also possible that a firewall along the way has been configured with a rule to refuse access to the service; however it is more common for firewalls to be configured to silently drop attempts to connect.
The mechanism by which connections are refused is the TCP reset (RST) flag, whether that is generated by the system hosting the service or a firewall.