The number of simultaneous network connections from other computers is limited in the desktop editions of Windows. For example, only 20 simultaneous incoming sessions (connections) are supported on Windows 10 and 11 (regardless of edition). When a computer running Windows 10/11 is used as a quasi-file server or print server, users receive an error when connecting if the TCP/IP session limit is exceeded:
No more connections can be made to this remote computer at this time because there are already as many connections as the computer can accept.
The Windows 11 End-User License Agreement (EULA) states that you cannot connect more than 20 devices to a desktop device simultaneously.
Microsoft restricts the non-server (desktop) edition of Windows from functioning as a full server, likely to encourage users to buy Windows Server licenses (or switch to samba😊).
Check the number of incoming sessions limit in Windows by using the command:
net config server
Current limit:
Maximum Logged On Users 20
16777216
. Note the value of the Idle session time (min)
parameter. By default, Windows disconnects a session that has been inactive for more than 15 minutes. If you want to disconnect unused sessions more quickly, reduce the timeout period (for example to five minutes).
net config server /autodisconnect:5
You can manually disconnect some devices if the number of simultaneous connections to the computer is exceeded. List the active network connections on this computer:
net session
Disconnect all active sessions from a computer (by hostname or IP address):
net session \\192.168.31.94 /d
To reset all active connections to a computer
net session /delete
If you want to automatically disconnect certain clients when the maximum number of connections is reached, you can use PowerShell automation. Below is an example of a simple PowerShell script that gets a list of active sessions and when it reaches 19 concurrent connections, it disconnects the 2 sessions with the longest timeouts (or use other logic).
$number_of_old_sessions_to_kill=2
$output = net session | Select-String -Pattern \\
$CurConns= ($output| Measure-Object -Line).Lines
if ($CurConns -ge 19) {
$sessions = @()
$output | foreach {
$parts = $_ -split "\s+", 4
$session= New-Object -Type PSObject -Property @{
Computer = $parts[0].ToString();
Username = $parts[1];
Opens = $parts[2];
IdleTime = $parts[3];
}
$sessions += $session
}
$oldsessions=$sessions|Sort-Object -Property IdleTime -Descending | Select-Object -First $number_of_old_sessions_to_kill
ForEach ($oldsession in $oldsessions) {
net session $($oldsession.Computer) /d /y
}
}
Use Task Scheduler to run this PowerShell script every N minutes to disconnect the idle sessions.
For earlier versions of Windows, patches to the tcpip.sys file can disable the session limit in desktop OS editions, similar to the RDP Wrapper library. But I haven’t seen any such patches for Windows 10 and 11 yet. In any case, their use is a violation of the license agreement.