IIS 6: Increase outbound TCP connections

IIS 6 has a default limit for the outbound TCP connections. It limits the number of outbound sockets that can be created. This limit is controlled with MaxUserPort in the registry.


According to Microsoft(R) this is only applied on Windows 2003 (R2, SP1, SP2).

[quote style=”boxed”]MaxUserPort: Specifies the highest port number that TCP can assign when an application requests an available user port from the system. Typically, ephemeral ports (those used briefly) are allocated to port numbers 1024 through 5000.[/quote]

This means that the limit for your outbound connections is 5000 – 1024 = 3976

In order to change this value use regedit.exe and browse to [highlight]HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters[/highlight] and change the default (5,000) to your desired max number (max 65,534).

max user port in registry
max user port in registry

Some cases you need to change MaxUserPort:

  • your have a service or application, from which every request to the Web Server is an outbound connection (6,000 requests = 6,000 outbound connections, in this case request model is something like one request = one outbound TCP connection (or more!)
  • You receive this error on your application logfile or event log: System.Net.WebException: Unable to connect to the remote server —> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted

… and I am sure you will find more cases you will need to change this.

 

Notes:

  • If you can’t find the MaxUserPort dword in the above registry path, just create it. (Restart your server after the registry change)
  • There are more limits controlling the outbound tcp connections and you can learn about them on article Configure the max limit for concurrent TCP connections