Windows – How to make WinXP bind to ports other than 1025-5000 for outgoing TCP connections

porttcpipwindows

(I originally posted a similar question on StackOverflow but readers recommended I post here instead)

When you create outgoing TCP connections, most applications let the operating system choose which port to use. Most OSes use the IANA recommended dynamic port range of 49152-65535 for this purpose. But in Windows 2003 and earlier (including XP) Microsoft uses ports 1025-5000. Microsoft lets you change the high end of this range via the MaxUserPort TcpIP registry setting, but I see no way to change the low end. I need to have port 4160 free for incoming connections and on rare occasions an outgoing connection steals that port from me before I bind that port.

Best Answer

In addition to MaxUserPort, you also need to specify ReservedPorts.

Registry Key: HKLM\System\CurrentControlSet\Services\TCPIP\Parameters

Registry Value: ReservedPorts Type: Multi-string value Value data: 1024-5000

You may also want to try only specifying 4160-4160 and not using ReservedPorts.