How to Keep a Remote Desktop Session Active and Stop Idle Disconnects
Remote Desktop sessions end for four reasons: an idle time limit set by policy, a network device that drops quiet connections, a lock screen on the remote PC, and a minimized window that stops drawing. The setting, registry value and PowerShell line for each.
Reading on your phone?
Run the idle test on your computer
Slack sets you away on your computer, so this free test runs there. Send yourself this page and press Start at your desk.
On this page
- 1. Why a Remote Desktop session disconnects
- 2. Check the current limits
- 3. Fix 1: raise the idle session limit (admin on the remote PC)
- 4. Fix 2: turn on keep-alive for quiet connections
- 5. Fix 3: stop the remote PC from locking or sleeping
- 6. Fix 4: keep a minimized session running
- 7. Without admin rights: keep the session busy
- 8. FAQ
To keep a Remote Desktop session active, fix the timer that is ending it. On the remote PC, set the Group Policy Set time limit for active but idle Remote Desktop Services sessions to Never (registry value MaxIdleTime = 0), and turn on Configure keep-alive connection interval at 1 minute so firewalls and VPNs do not drop the quiet connection. Then make sure the remote PC itself does not lock, and, if scripts run in the session, stop the client from pausing a minimized window. If you cannot change policy, only input inside the session resets the idle timer. If you keep the session alive so Slack stays green, Slack Green keeps your Slack dot green from a server with no session open at all, free for 7 days with no card.
Why a Remote Desktop session disconnects
| What you see | Cause | Fix |
|---|---|---|
| "Idle timer expired" warning, then a disconnect | Idle session time limit policy | Set it to Never, or longer (admin) |
| Disconnect after a quiet spell, no message | Firewall, VPN or NAT drops the idle TCP connection | Keep-alive connection interval, 1 minute |
| Session logged off hours after you disconnect | Disconnected session time limit | Raise Set time limit for disconnected sessions |
| Lock screen inside the remote session | Screen saver or lock policy on the remote PC | Change the remote PC's lock timeout |
| Scripts stop while the window is minimized | The client stops drawing a minimized session | RemoteDesktop_SuppressWhenMinimized = 2 |
| Kicked out when someone else signs in | One session per user, or per PC on Windows 10 and 11 | Separate accounts, or reconnect |
The idle limit shows a dialog first: "Session has been idle over its time limit. It will be disconnected in 2 minutes. Press any key now to continue session." If you see that text, the policy is the cause. A drop with no warning is almost always the network.
Keeping the Remote Desktop session open does not keep Slack green on its own, because Slack sets you away 10 minutes after your last keyboard or mouse input. A server-side tool keeps your Slack dot green with no input, even with no Remote Desktop session open.
Check the current limits
Run this in PowerShell on the remote PC. It reads the policy values Group Policy writes. An empty result means no policy is set, and Windows uses its defaults or the per-user limits in the account's Sessions tab.
Get-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -ErrorAction SilentlyContinue |
Select-Object MaxIdleTime, MaxDisconnectionTime, KeepAliveEnable, KeepAliveInterval
MaxIdleTime and MaxDisconnectionTime are in milliseconds: 900000 is 15 minutes, and 0 means no limit. KeepAliveInterval is in minutes. gpresult /h rdp.html shows which Group Policy object set each value.
Fix 1: raise the idle session limit (admin on the remote PC)
In the Group Policy editor (gpedit.msc), open Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Session Time Limits, and set:
- • Set time limit for active but idle Remote Desktop Services sessions: Enabled, Never.
- • Set time limit for disconnected sessions: Enabled, a limit that suits you, such as 1 day, so a dropped session is still there when you reconnect.
The same change from an elevated PowerShell, for a single PC outside domain policy:
# run as administrator on the remote PC; 0 = never end an idle session
$key = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services'
New-Item -Path $key -Force | Out-Null
Set-ItemProperty -Path $key -Name MaxIdleTime -Value 0 -Type DWord
Set-ItemProperty -Path $key -Name MaxDisconnectionTime -Value 86400000 -Type DWord # 1 day
gpupdate /force
On a domain PC, a domain Group Policy overwrites local values at the next refresh, so ask whoever manages it. On a Remote Desktop Services server, the collection's Session tab in Server Manager has the same End an idle session setting. Company servers set these limits on purpose to free licenses and memory, so do not change them without the admin.
Fix 2: turn on keep-alive for quiet connections
A VPN, firewall or home router can drop a TCP connection that sends nothing for a few minutes. The Remote Desktop keep-alive sends a small packet on a timer so the connection never looks idle to the network. It does not count as user input, so it does not reset the idle session timer in Fix 1.
The policy is Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Connections > Configure keep-alive connection interval: Enabled, 1 minute. As registry values on the remote PC:
$key = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services'
Set-ItemProperty -Path $key -Name KeepAliveEnable -Value 1 -Type DWord
Set-ItemProperty -Path $key -Name KeepAliveInterval -Value 1 -Type DWord
Fix 3: stop the remote PC from locking or sleeping
The session can stay connected while the remote PC shows its own lock screen after its screen saver or lock timeout. Change the lock and sleep settings on the remote PC, as you would at its desk; see how to stop Windows 11 from locking and how to stop your computer from sleeping. A remote PC that sleeps drops the session, so set it to never sleep while plugged in:
powercfg /change standby-timeout-ac 0
Fix 4: keep a minimized session running
When you minimize the Remote Desktop window, the client stops drawing the remote screen. Scripts and automation that click or type in the session can then fail. On the computer you connect from, add this value, then reconnect:
reg add "HKCU\Software\Microsoft\Terminal Server Client" /v RemoteDesktop_SuppressWhenMinimized /t REG_DWORD /d 2 /f
Without admin rights: keep the session busy
If you cannot change policy, only input inside the remote session resets its idle timer. Moving the mouse on your own computer does nothing while the Remote Desktop window is in the background. A key-press loop that runs inside the session works, because the input is created on the remote PC. The F15 PowerShell loop in keep your computer awake with PowerShell is the common one: F15 is on almost no keyboard, so it does not type into your apps. Check your company's policy first, because an idle limit on a company server is usually there on purpose.
FAQ
How do I stop Remote Desktop from disconnecting when idle? Set "Set time limit for active but idle Remote Desktop Services sessions" to Never on the remote PC, and turn on the keep-alive interval at 1 minute.
Does this apply to VMware Horizon? Horizon uses its own agent policy and a 10-hour session limit; see VMware Horizon idle timeout.
What is the default RDP idle timeout? Windows sets no idle limit by default. A timeout you hit comes from Group Policy, the account's Sessions tab, an RDS collection setting, or the network.
Does moving my mouse keep a Remote Desktop session active? Only when the pointer moves inside the Remote Desktop window. Input on your own desktop does not reach the session.
Why does my RDP session disconnect after exactly 15 minutes? A policy set the idle limit to 15 minutes. Check MaxIdleTime with the PowerShell line above.
Does the RDP keep-alive stop the idle timeout? No. Keep-alive stops the network from dropping the connection. The idle session limit counts user input only.
Related Articles
PowerToys Awake Managed by Your Organization: What It Means
PowerToys shows 'This setting is managed by your organization' when your IT team set a group policy for Awake. A value of 0 forces Awake off and greys out the toggle; 1 forces it on. How to see which policy applies with one reg query, why Awake exits when started from the command line, and what you can still do.
VMware Horizon Idle Timeout: Which Timer Disconnected You
Horizon does not disconnect idle sessions by default. When yours drops, one of these set it: the Idle Time Until Disconnect (VDI) agent policy, the 10-hour Forcibly disconnect users limit, a logoff after disconnect in the pool, the Windows lock inside the desktop, or your own laptop going to sleep. How to tell which, and what counts as activity.
AutoHotkey Script to Keep Your Computer Awake (v2 Code)
Three AutoHotkey v2 scripts that keep a Windows PC awake: one calls SetThreadExecutionState and sends no input, one presses F15 after 4 idle minutes so Teams stays green, and one nudges the mouse by a pixel. How to run them, start them with Windows, and what they do not fix.