Thanks, not AI - I'm not a Windows pro and have no clue where to find nor edit these policies.
How do I prevent remote desktop sessions from closing when my screen lock activates?
I'm working on a remote PC via RDP and all is great. But, when I take a short break and lock my local PC, it closes the RDP session forcing me to log in to the remote again. As well, this happens during the screen saver timeout.
How do I lock my local PC without dropping the remote connection?
A further clue is that a piece of test equipment that I'm connected to via a web interface also closes under the same conditions. So it's almost as if Windoze pauses my network connections, breaking both.
The remote computer is running a recent version of Ubuntu (22.04 I believe). This has worked fine in other instances, leading me to believe the problem is with the client rather than the server.
Windows 11 Enterprise 25H2, connected via wifi
Windows for business | Windows Client for IT Pros | User experience | Remote desktop clients
2 answers
Sort by: Most helpful
-
AI answer
2026-03-12T22:06:53.7366667+00:00 The behavior is controlled by how Remote Desktop handles session lock and disconnection, plus any policies that force a disconnect instead of keeping the session active.
Key points from the platform behavior:
- A Remote Desktop session can be in these states: Active, Idle, Locked, or Disconnected. When it becomes Disconnected, the RDP window closes and a reconnect is required. The session itself continues to run on the remote machine.
- Lock and disconnect behavior is driven by policies and configuration. Policies always override defaults, and computer‑level policies override user‑level policies.
- There are specific policies that decide whether a session stays on the lock screen or is forcibly disconnected when locked:
-
DisconnectOnLockLegacyAuthn– applies when using legacy authentication (username/password, smart card, NTLM, CredSSP, TLS, etc.). -
DisconnectOnLockMicrosoftIdentityAuthn– applies when using Microsoft Entra (Azure AD) / Microsoft identity platform authentication.
-
To keep the remote session from closing when lock/screen saver activates, ensure the environment is configured to show a lock screen instead of disconnecting, and that session timeouts are not forcing a disconnect.
1. Check whether the session is being locked vs disconnected
On the remote host, confirm whether the session is:
- Locked: user is redirected to the login screen, session remains active.
- Disconnected: RDP window closes with an error, session remains on the server but the client must reconnect.
If the session is being disconnected on lock, the disconnect‑on‑lock policies are likely enabled.
2. Review and adjust disconnect‑on‑lock policies
If using legacy authentication to the remote PC or RDS host:
- Policy path (MDM CSP):
-
./Device/Vendor/MSFT/Policy/Config/RemoteDesktopServices/DisconnectOnLockLegacyAuthn
-
- Behavior:
- Enabled: Remote Desktop connections using legacy authentication will disconnect the remote session when it is locked.
- Disabled or Not configured: Remote Desktop connections using legacy authentication will show the remote lock screen when locked; users can unlock with username/password or certificates.
To avoid disconnects when the session locks, this policy must be disabled or not configured on the device.
If using Microsoft Entra authentication:
- Policy path (MDM CSP):
-
./Device/Vendor/MSFT/Policy/Config/RemoteDesktopServices/DisconnectOnLockMicrosoftIdentityAuthn
-
- Behavior:
- Enabled or Not configured: Remote Desktop connections using Microsoft identity platform will disconnect the remote session when locked.
- Disabled: Remote Desktop connections using Microsoft identity platform will show the remote lock screen when locked.
To keep the session from closing on lock when using Entra authentication, this policy must be disabled.
These are device‑scope policies, so they must be set by the administrator via MDM or equivalent management.
3. Check for other timeout and lock policies
If the session is closing after a period of inactivity or when the screen saver activates, verify:
- RDS session timeout vs lock:
- Disconnections with no consistent timing pattern are more likely network‑related.
- Consistent timeouts usually indicate configured session timeouts or lock policies.
- Lock‑related settings on the remote machine:
- Machine inactivity limit policy:
- Policy path:
Computer Configuration > Windows Settings > Security Settings > Local Policies > Security Options > Interactive logon: Machine inactivity limit - Registry:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System–InactivityTimeoutSecs(REG_DWORD, seconds) - When configured, the session is locked after the specified idle time.
- Policy path:
- Screen saver lock settings (user configuration):
- Registry:
HKCU\Control Panel\DesktopandHKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop - Values such as
ScreenSaveActive,ScreenSaverIsSecure, andScreenSaveTimeOutcontrol whether a screen saver starts and whether it locks the session.
- Registry:
- Machine inactivity limit policy:
Policies have precedence over defaults, and computer policies over user policies. If policies are forcing a lock that then triggers disconnect‑on‑lock, the result is the behavior being observed.
4. Automatic reconnection considerations
Remote Desktop supports Automatic Reconnection, which keeps session state and reconnects seamlessly after temporary network disruptions. However, if the environment is configured to disconnect on lock, the session will not remain at a lock screen and automatic reconnection will not behave like a persistent, locked session. Disabling disconnect‑on‑lock (as above) is required to allow a traditional lock‑screen experience.
References:
AI-generated content may be incorrect. Read our transparency notes for more information.