Winsock Error Codes - Brought to you by Winsock-Error.com

10061 "Connection refused."

WSAECONNREFUSED (Winsock error number: 10061)

Microsoft say this about Winsock error 10061 - WSAECONNREFUSED:

No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.

Full details of Winsock TCP error 10061 - WSAECONNREFUSED:

Berkeley description: No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host.

WinSock description: Same as Berkeley

TCP/IP scenario: In TCP terms (datastream sockets), it means an attempt to connect (by sending a TCP SYN packet) caused the destination host to respond to the host by returning a reset (a TCP RST packet). If an application sends a UDP packet to a host/port that does not have a datagram socket "listening," the network system may respond by sending back an ICMP Port Unreachable packet

User suggestions: Either you went to the wrong host, or the server application you're trying to contact isn't executing. Check the destination address you are using. If you used a hostname, did it resolve to the correct address? If the hostname resolution uses a local hosttable, it's possible you resolved to an old obsolete address. It's also possible that the local services file has an incorrect port number (although it's unlikely).

You can verify that the remote system is rejecting your connection attempt by checking the network statistics locally. Check that your network system (WinSock implementation) has a utility that shows network statistics. You could use this to verify that you're receiving TCP resets or ICMP Port Unreachable packets each time you attempt to connect.

Developer suggestions: If you have a network analyzer available, you can quickly check if the destination port number and host address are what you expect. On the server end, you could use a network system utility similar to BSD's "netstat -a" command to check that your server is running, and listening on the right port number.

This is one of the most frequent errors and one of the best to encounter, since it's one of the least ambiguous. There are only a few possible causes for this error:

  • you tried to connect to the wrong port. This is a common problem. You need to call to translate a constant value to network byte order before assigning it to the sin_port field in the sockaddr structure.
  • you tried to connect to the wrong destination host address
  • the server application isn't running on the destination host
  • the server application isn't listening on the right port. The server application might need to call to translate the port to network byte order in the sockaddr structure.

   
This page is designed to help you to understand Winsock TCP error 10061. It will not necessarily mean you can instantly fix issues when your computer tells you that Winsock is having problems with code 10061, rather it will give you the necessary background information to help solve the matter.

Programming declarations for 10061 (WSAECONNREFUSED):

C#
long WSAECONNREFUSED = 10061 ;

VB.net
Dim WSAECONNREFUSED As Long = 10061

VB6
Dim WSAECONNREFUSED As Long
WSAECONNREFUSED = 10061