Resolving Winsock Error 10013 (WSAEACCES)
Winsock error 10013 (WSAEACCES) means that Windows denied the requested socket operation. The error message is typically "An attempt was made to access a socket in a way forbidden by its access permissions." The sections below describe the most common causes.
Raw Sockets in the ICMP Components
By default, the ICMP and Ping components use raw sockets, which on Windows can only be created by applications that run with administrator privileges. To send ping requests without administrator privileges, set the UseIPHLPDLL configuration setting to true.
ping.Config("UseIPHLPDLL=true");
ping.PingHost("www.example.com");
For more information, please see our Resolving Access Denied Errors with the ICMP Components entry.
Reserved or Exclusively Used Ports
When a component listens on a port (e.g., the TCPServer component, or a UDP component with the LocalPort property set), error 10013 can occur when the port cannot be used by the application:
- The port is in an excluded port range. Windows reserves ranges of ports for other features (e.g., Hyper-V, WSL, Docker, and Windows NAT), and binding to a port in a reserved range fails with error 10013. The reserved ranges can be listed with the command below. To resolve the error, use a port outside these ranges.
- The port is used by another application with exclusive access. When another application already uses the port and has opened it for exclusive use, binding to the same port fails with error 10013 (instead of error 10048, "Address already in use"). The application that uses the port can be found with netstat -ano, which shows the process ID of each listening socket.
netsh interface ipv4 show excludedportrange protocol=tcp
netsh interface ipv4 show excludedportrange protocol=udp
Sending to a Broadcast Address
Sending a UDP datagram to a broadcast address requires broadcasting to be enabled on the socket, and Windows returns error 10013 when it is not. The UDP component enables broadcasting automatically when the RemoteHost property is set to the limited broadcast address 255.255.255.255.
udp.RemoteHost = "255.255.255.255";
udp.RemotePort = 9;
udp.Activate();
udp.SendText("Hello");
Firewalls and Security Software
Firewalls, antivirus software, and other endpoint security software can block applications from using the network, or from listening on specific ports, in which case the operation fails with error 10013. If none of the causes above apply, check whether the application is allowed by this software.
Note that older versions of Windows (Windows NT 4.0) allowed standard users to create raw sockets by setting the DisableRawSecurity registry value. This is not supported on current versions of Windows.
Note that in older versions, the ICMP component was named ICMPPort.
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.