WSAECONNREFUSED No connection could be made because the target machine actively refused it.

One possible cause of this socket connect error is when an Anti-Virus program blocks the connection. This can happen if the AV program is blocking the outbound port. If some programs can connect to a given remote host:port, but your application cannot, then check your Anti-Virus program to see if exceptions were made for specific programs, but not for your application’s EXE.

Anti-Virus Blocking Application’s SMTP Connection

Occasionally, Chilkat will receive a support email from a customer with a problem described this way: Outlook can connect to my SMTP server and send email, but my application cannot. I’ve checked the settings and they are identical to those used by Outlook. What could the problem be?

The problem is often caused by an Anti-Virus program. The AV program allows known applications, such as Outlook, to send email, but blocks unknown applications (i.e. your application). The solution is to determine how to configure your Anti-Virus program to make an exception for your application (in other words — make your application a known non-threat).

The most recent customer having this problem was using Norton Anti-Virus while trying to connect to the HotMail SMTP server. The result of Norton AV blocking the connection was a 503 response to the SMTP STARTTLS command, as shown in the LastErrorText below:

<info>Connecting to SMTP server</info>
<InitialResponse><![CDATA[220 Microsoft ESMTP MAIL Service, Version: 6.0.3790.2668 ready at  Wed, 4 Mar 2009 23:29:09 -0800 
<info>Sending STARTTLS (1)...</info>
<info>Received 503 SMTP Status...</info>
<error>Connection closed by server.</error>
<error>Failed to get EHLO response (2)</error>
<error>Failed to connect to SMTP server.</error>