What is a TCP Connection Refused?

In general, 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:

  1. Misconfiguration, such as where a user has mistyped the port number, or is using stale information about what port the service they require is running on.
  2. A service error, such as where the service that should be listening on a port has crashed or is otherwise unavailable.

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.