Sometimes users cannot connect to RDS farm servers running Windows Server using the built-in RDP client (mstsc.exe) with the following error:
The task you are trying to do can't be completed because Remote Desktop Services is currently busy. Please try again in a few minutes. Other users should still be able to log on.
In this case, the RDS host admin can see a lot of stuck user sessions with the name (4) instead of usernames and Disconnected status in the Users tab of Task Manager.
The problem occurs in all Windows Server versions: 2008 R2, 2012 R2, 2016 and 2019.
The error may appear on a number of reasons:
- An error in the operation of the Remote Desktop Services;
- A bug in the csrss.exe process;
- An issue with a user profile or profsvc service;
- Lack of RAM or disk space on the RDSH server;
- Incorrect Group Policy settings.
Unfortunately, there is no official Microsoft solution able to solve the problem completely. All you can do is to get rid of symptoms.
Almost always troubleshooting implies reset of a problem user session or RDS server restart, but in some cases the problem persists. Let’s study the solutions starting with the easiest one.
Check RDS Server Resources
Make sure that you have enough server resources since the problem may occur due to the lack of RAM or disk space. Check the RAM load and how much free space is left on the disk with the operation system installed (there must be at least 1GB). Also, view the event log to see if there are any critical errors related to RDS.
If everything is ok, move on to the next step.
Reset Stuck Client Remote Desktop Session on RDS
First of all, try to find and reset a session of a user who cannot logon to the RDS server with the error “Remote Desktop Service is currently busy”. Find a user in the Users tab of the Task Manager and click Log off in the context menu. In most cases it is enough to solve a problem, but sometimes you can find multiple hung sessions with the name (4) instead of a username in the Task Manager. As a rule, there will be 4 processes in a hung RDS user session:
- Client Server Runtime Process (csrss.exe)
- Desktop Windows Manager (dwm.exe)
- Windows Logon Application (winlogon.exe)
- Windows Logon User Interface
To start with, try to reset all hung (4) RDS sessions in the Task Manager as described above. If it doesn’t help, it is better to reboot the server. But this is often not possible, as it will affect other users’ sessions on RDS host. So we will try to solve the problem without rebooting the host:
- Run the elevated command prompt and execute the command:
query session
It will show all users and their remote sessions on the RDS host. There are 3 columns we need in the output: SESSIONNAME, USERNAME and ID. Find the(4)
user and the corresponding ID, in this example it is ID 2. We must to kill thecsrss.exe
process that is working in this session, but we’ll have to find it first; - Display the list of running process in the session ID you received earlier:
query process /id 2
Find thecsrss.exe
process (check the IMAGE column) and its PID. In my case, the PID is 5140. You need to kill this process. - Check it in the Task Manager. Open the Task Manager, go to the Details tab and find the PID and the process from the previous step. If the PID you need corresponds to the csrss.exe process, kill the process by clicking End task in the context menu or by entering the following command in the command prompt:
taskkill /F /PID 5140
Do it for each (4) user if there are some of them.
Resetting an RDS User Session
If you were not able to log off a problem user in the Task Manager, you can try to reset an RDS user session from the command prompt:
- Open the command prompt as administrator and run the command:
query session
Copy the SESSIONNAME of the problem user. - Enter:
reset session <SESSIONNAME>
Specify the session name you have instead of <sessionname> as shown in the screenshot below:
Do it for each problem RDS user session. Then you may try to log on and a problem should not occur again. If you can restart your server, it is better to do it.
Check Licensing Settings on your RDS Host
Make sure that the license server and license type (CAL Per User/ CAL Per Device) specified on your RDS host are correct. Once I got the error ‘The task you are trying to do can’t be completed because Remote Desktop Services is currently busy’ when after the installation of the RDSH role I forgot to specify the hostname/IP address of the server with the Remote Desktop Licensing role. In that case, two RDP users connected as usual and the third one faced this error.
You can specify the address of the server with RDS licenses:
- In the RDS collection settings: Tasks -> Edit Deployment Properties -> RD Licensing -> Specify a license server;
- In GPO: Use the specified Remote Desktop license servers (Computer Configuration -> Policies -> Admin Templates -> Windows Components -> Remote Desktop Services -> Remote Desktop Session Host -> Licensing)
- Using PowerShell.
Remove the RDP Connection Limit in GPO
You can use Group Policies to limit the number of concurrent (simultaneous) RDS connections. This policy setting is disabled by default.
Make sure if the policy is enabled and get its value using gpresult.
- Run the following command in the elevated command prompt:
gpresult /H c:\gpresult.html
- Open the gpresult.html file located in the root of disk C. It is a common .html file and it is recommended to open it in the Internet Explorer since it may be displayed incorrectly in other browsers;
- Find the GPO setting named Limit number of connections under Computer Configuration -> Administrative Templates -> Windows Components -> Remote Desktop Services -> Remote Desktop Session Host\Connections or type Limit number of connections to search on page
If there is no such policy settings, it is not applied and there are no restrictions on the number of concurrent connections. If the policy is enabled and the maximum number of connections is set, change the value as you want. You can edit a local Group Policy Editor (gpedit.msc
), and if the policy is set using domain GPO, edit it in gpmc.msc
. After you have done it, don’t forget to run the command gpupdate /force
to refresh and apply the new Group Policy settings immediately.
Out-of-the-box Solutions: What to Do If Nothing Helps
If you have enough server resources, see no errors in RDP logs, resetting the user’s session didn’t help for some reason, and can’t restart the RDSH host immediately, then you should try the following options:
- Make sure that the Drain mode preventing users from creating new RDP connections is disabled:
chglogon.exe /QUERY
. If the command returns ‘New user logons are DISABLED, but reconnections to existing sessions are ENABLED,’ disable Drain mode:chglogon.exe /enable
- Uncheck Persistent bitmap caching in the RDP connection settings of the
mstsc.exe
client; - Restart the Remote Desktop Service using the commands:
net stop termservice
andnet start termservice
. Or restart the service remotely using PowerShell:Get-Service termservice –ComputerName mun-rdsh1 | Restart-Service
- Kill all tstheme.exe processes;
- It is recommended to apply all latest updates for your Windows version, use standard update tools (or the PSWindowsUpdate PowerShell module).