We are regularly experiencing strange issues with networking on our dedicated server. It runs Windows Server 2012 R2 x64 on Xeon E5620 with 16 GB RAM and Intel 82575EB network adapter.

Please note that we've already tuned HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters key values TcpTimedWaitDelay and MaxUserPort to 30 and 65530 respectively.

At a random point of time our websites stop responding, the reason being they cannot connect to a local database. It's approximately 2 weeks uptime when this issues start taking place. The system log starts getting TCPIP warnings 4227 and 4231.It states "A request to allocate an ephemeral port number from the global TCP port space has failed due to all such ports being in use.".

If I run

Get-Counter -Counter \TCPv4\*


Get-Counter -Counter \TCPv6\*


netstat -abn | find /c ":"

I always get reasonable value of 500-1500 connections, which is not even close to 65K limit.

Additionally, "localhost" stops resolving to ::1 locally, reverting to
Only a forced machine restart can resolve the situation.

Could it be a network adapter problem?


It happened again and seemed to have been resolved when I restarted the mail server. Weird though, all the counters showed ~1000 connections with ~500 being active at the moment, and still the 10055 socket error when trying to connect to the database which has nothing to do with the mail server.

UPDATE 2 This IS strange, but the daily restart of the mail services fixes the problem completely.


4 Answers 4


I've had similar problem with exhausted pool of TCP/IP ports on WinSvr 2012R2 x64 for almost 1 month where server stopped receiving any new and TCP connections. So I played with registry values and these are stable for me:

  • TcpTimedWaitDelay - 30
  • MaxUserPort - 65534
  • TcpNumConnections - should be in default state stretched to maximum = 16777214 should prevent server from exhausting ephemeral ports.
  • TcpMaxDataRetransmissions - Timeout limit of TCP unacknowledged data segments retransmission on actual connection = 5.

In result same like yours. I think you should consider to audit your behavior of your applications/scripts performance. If everything is ok and nothing help, then you can try to put proxy server before your web application server, make 2 nodes with web server (IIS, Apache, ...) which will share same static content and access same database at the same time (if you have enough resources in your company).

Maybe this article would help you in some way: http://blogs.technet.com/b/tristank/archive/2008/03/11/maxuserport-what-it-is-what-it-does-when-it-s-important.aspx

  • 1
    You should've read the question thoroughly before answering. Of course I did try this solution before asking, it's very common. I've already solved the problem by another means.
    – CamaroSS
    Jan 12, 2015 at 13:08
  • 1
    I think daily restart of the mail services is not solved problem. Have you found another solution?
    – MyKE
    Jan 12, 2015 at 13:22
  • 4
    @CamaroSS: Please share your solution (if it goes beyond "restarting the mail service" - this is not a solution). Also, maybe you should appreciate it a bit more if someone tries to help you.
    – Sven
    Jan 12, 2015 at 13:22
  • @CamaroSS And if you read carefuly my answer you'll see "In result same like yours", then I've posted another information..
    – MyKE
    Jan 12, 2015 at 13:23
  • 1
    Does setting MaxUserPort still work in 2012? I thought in 2012 you must do it via netsh. e.g.: netsh int ipv4 set dynamicport tcp start=25535 num=40000
    – rustyx
    Oct 20, 2015 at 12:19

In addition to the Tcpip driver settings, the ephemeral TCP port range is managed in Windows Server using the netsh command (source).

You can view the dynamic port range with the following commands:

  • netsh int ipv4 show dynamicport tcp
  • netsh int ipv4 show dynamicport udp
  • netsh int ipv6 show dynamicport tcp
  • netsh int ipv6 show dynamicport udp

To change the port range, use this command:

  • netsh int <ipv4|ipv6> set dynamic <tcp|udp> start=number num=range

For example:

netsh int ipv4 set dynamicport tcp start=49152 num=16384

The setting (start=49152 num=16384) is also the default on Windows Server 2008 onwards.

  • Thank you so much for this - I've already spent hours on trying to solve my problem. All the advice I could find was about adjusting MaxUserPort in the registry and nobody mentioned netsh.
    – milosz
    Aug 8, 2017 at 7:14

Had this same issue on Windows Server 2016 running large amounts of Selenium tests using chromewebdriver. This PS script will automatically configure the settings @Myke shared above. The shutdown command was added because a reboot is required for the TCP stack changes.

Increase Pool Size for Ephemeral TCP Ports

Get-Item 'HKLM:\System\CurrentControlSet\Services\Tcpip\Parameters' | New-ItemProperty -Name MaxUserPort -Value 65534 -Force | Out-Null
Get-Item 'HKLM:\System\CurrentControlSet\Services\Tcpip\Parameters' | New-ItemProperty -Name TcpTimedWaitDelay -Value 30 -Force | Out-Null
Get-Item 'HKLM:\System\CurrentControlSet\Services\Tcpip\Parameters' | New-ItemProperty -Name TcpNumConnections -Value 16777214 -Force | Out-Null
Get-Item 'HKLM:\System\CurrentControlSet\Services\Tcpip\Parameters' | New-ItemProperty -Name TcpMaxDataRetransmissions -Value 5 -Force | Out-Null

shutdown -r -t 0

This was the error message we were receiving on Webdriver.Quit() telling us that a TCP address was in use.

Error: EADDRINUSE connect EADDRINUSE at ClientRequest. (\node_modules\selenium-webdriver\http\index.js:238:15)
From: Task: WebDriver.quit()


Have you made sure that you are not leaking database connection objects? You have to close every database connection that is opened, either explicitly (with try-finally) or with a using { } block. This is a common problem that ASP won't directly tell you about.

  • It's a bunch of PHP sites, most of them are running via FastCGI using persistent connection, so it shouldn't be the case. If it was, then the system counters would return way higher values. I also can't explain why localhost suddenly stops to resolve to ::1 and resolves to instead.
    – CamaroSS
    Dec 14, 2014 at 7:56
  • 2
    ::1 disappearing is probably just a side effect of overflowing the allowable ports--I suspect that windows tries an IPv6 ping and when it can't get a port to make the attempt, it falls back to IPv4. PHP is outside my areas of expertise. :-(. Good luck!
    – James
    Dec 15, 2014 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.