To fix "An internal error has occurred" in Windows Remote Desktop: Grant Everyone Read/Write access and Administrators Full Control to C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys via icacls, configure SecurityLayer to 1 (Negotiate) in HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp, restart the TermService service, and clear client cached credentials with cmdkey /delete.[1]
Follow this step-by-step production runbook to isolate whether the failure stems from cryptographic permission locks, Network Level Authentication (NLA) handshake timeouts, or client-side caching glitches.[2]
Technical Root Cause Analysis of Remote Desktop “An Internal Error Has Occurred”
The error message “An internal error has occurred” is generated by the Windows Remote Desktop Client (mstsc.exe) when an unhandled failure occurs during the protocol negotiation or security handshake phase before a full desktop session initializes.[1] Unlike specific transport errors such as 0x204 (port unreachable) or CredSSP Oracle Remediation warnings, the internal error indicates that the client initiated a TCP connection on port 3389, but the cryptographic or security handshake broke down midway.[3]
What Causes “An Internal Error Has Occurred” in Remote Desktop?
Production incident post-mortems across enterprise Windows Server environments categorize the root cause into five distinct failure domains:
- Cryptographic MachineKeys Permission Locks: The Remote Desktop service (
TermService) and Microsoft Schannel provider require access to RSA private keys stored in%ProgramData%\Microsoft\Crypto\RSA\MachineKeys. When automated hardening scripts or operating system upgrades strip write permissions for the localNETWORK SERVICEorEveryonegroup, Schannel fails to generate or read the self-signed TLS certificate required for session encryption.[4] - SecurityLayer and NLA Negotiation Mismatch: If the server enforces TLS-only encryption (
SecurityLayer = 2) but possesses an expired or improperly bound X.509 certificate, or conversely, if the client attempts native RDP encryption against an NLA-mandated host (UserAuthentication = 1), the session terminates instantly.[2] - Remote Audio & Peripheral Redirection Thread Timeouts: When
mstsc.exeattempts to map virtual audio playback or microphone recording channels over high-latency WAN connections, the server-side Windows Audio service (AudioSrv) can deadlock while initializing the endpoint, timing out the session handshake after roughly 45 to 60 seconds.[5] - Corrupted Client Bitmap and Credential Caches: Stale domain security identifiers (SIDs) or cached Kerberos tickets in Windows Credential Manager cause authentication mismatches that present as generic internal client failures.[1]
- MTU Size and TCP Packet Fragmentation: Over site-to-site IPsec, WireGuard, or SSL VPN tunnels, path MTU (Maximum Transmission Unit) discovery failure causes large TLS handshake packets to be dropped without generating ICMP fragmentation notifications.[6]
Diagnostic Matrix: Client-Side vs. Server-Side Failure Modes
Use this diagnostic matrix to categorize symptoms and target the appropriate operational tier:
| Symptom / Observation | Suspected Subsystem | Responsible Layer | Primary Remediation Action |
|---|---|---|---|
| Immediate disconnect within 1 second of entering credentials | Schannel / MachineKeys permissions | Server-side OS | Restore icacls permissions on RSA MachineKeys directory |
| Connection hangs on “Securing remote connection” for 60s, then fails | Windows Audio / Printer redirection | Server or Client | Set Remote Audio to “Do not play” in mstsc.exe options |
Fails from external WAN but connects from localhost console |
MTU size or perimeter firewall policy | Network / VPN | Lower client network MTU to 1360; inspect stateful inspection rules |
| Specific user fails while other administrative accounts succeed | Windows Credential Manager cache | Client-side OS | Purge cached target entries via cmdkey /delete |
| Fails following Windows Cumulative Updates or sysprep image capture | TLS cipher suite / RDP-Tcp Registry | Server-side OS | Set SecurityLayer = 1 and reset Terminal Server certificate |
How to Fix “An Internal Error Has Occurred” When Connecting to a Windows VPS
When connecting to a remote virtual server or enterprise dedicated server, resolve client-side and transport anomalies first before modifying remote host configurations.
Step 1: Client-Side Cache Eviction and Saved Credential Purge
Corrupted credentials or stale session hashes stored on your local workstation cause rapid handshake terminations.
Open Command Prompt as Administrator on your local machine and audit stored credentials:
cmdkey /list
Identify any records beginning with TERMSRV/ matching your server’s public IP address or FQDN, and delete them:
cmdkey /delete:TERMSRV/192.0.2.100
Next, clear the local Terminal Server Client bitmap and configuration caches:
del /f /q "%LOCALAPPDATA%\Microsoft\Terminal Server Client\Cache\*"
The hidden file %USERPROFILE%\Documents\Default.rdp retains persistent window coordinates, display scaling ratios, and custom gateway strings. If credential deletion does not resolve the client-side freeze, rename Default.rdp to Default.rdp.bak to force the client to regenerate a pristine configuration baseline.
Step 2: Audio and Peripheral Redirection Bypass in mstsc.exe
If the connection progress dialog freezes on “Configuring remote session…” for 30 to 60 seconds before throwing the internal error, audio redirection thread deadlocks are the primary cause.[5]
- Launch
mstsc.exefrom the Windows Run prompt (Win + R). - Click Show Options in the bottom left corner.
- Select the Local Resources tab.
- Under the Remote audio section, click Settings….
- Under Remote audio playback, select Do not play.
- Under Remote audio recording, select Do not record. Click OK.
- Under Local devices and resources, uncheck Printers and Smart cards temporarily to verify basic transport initialization.
Step 3: MTU Packet Size Optimization for VPN and High-Latency Tunnels
When connecting to cloud infrastructure across encrypted tunnels, packet overhead can exceed standard 1500-byte Ethernet frames, triggering silent packet drops during TLS certificate exchange.
Inspect your active network adapter subinterfaces:
Get-NetIPInterface | Select-Object InterfaceAlias, NlMtuMetric, InterfaceMetric
Adjust the MTU of your active network adapter (such as Ethernet, Wi-Fi, or VPN tunnel) to prevent fragmentation:
netsh interface ipv4 set subinterface "Ethernet" mtu=1360 store=persistent
How Do MachineKeys Folder Permissions Affect Remote Desktop Connections?
When the Remote Desktop service starts or accepts a secure TLS connection, the Microsoft Schannel security support provider reads and writes cryptographic keys stored inside the protected operating system path:
C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys
If permissions on this folder are stripped or corrupted during administrative security audits, antivirus scans, or disk cloning, the server cannot access its RSA keys.[4] Schannel outputs Event ID 36870 (“A fatal error occurred when attempting to access the TLS server credential private key”), resulting in an immediate “An internal error has occurred” prompt on the connecting client.[3]
Step 4: Repairing Schannel MachineKeys Cryptographic Permissions via PowerShell
Connect to your server via out-of-band management (VNC, IPMI KVM, or Cloud Hypervisor Web Console) and launch PowerShell as Administrator.
Verify the current Access Control List (ACL) on the MachineKeys directory:
icacls "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys"
Restore the canonical Microsoft NTFS permissions using icacls:
# Take ownership as local Administrators group
takeown /F "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys" /A
# Grant Administrators full control
icacls "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys" /grant "BUILTIN\Administrators:(F)"
# Grant Everyone special create and write permissions without directory listing inheritance
icacls "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys" /grant "Everyone:(R,W)"
# Grant SYSTEM full control
icacls "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys" /grant "NT AUTHORITY\SYSTEM:(F)"
Never run recursive inheritance (/T or /reset) blindly across all files inside MachineKeys. Existing private keys utilized by IIS, Active Directory Certificate Services, or SQL Server maintain unique per-file SID permissions. Only modify permissions on the parent directory container unless troubleshooting the specific Terminal Server key.
Generating a New Self-Signed Terminal Server Certificate
If the existing self-signed RDP certificate was corrupted while permissions were broken, regenerate a fresh certificate and bind it to the listener:
# Stop Remote Desktop Service
Stop-Service -Name TermService -Force
# Delete old corrupt Terminal Server self-signed certificate
Get-ChildItem -Path "Cert:\LocalMachine\Remote Desktop" | Remove-Item -Force
# Start Remote Desktop Service to automatically regenerate certificate
Start-Service -Name TermService
Upon restart, TermService creates a fresh RSA keypair in MachineKeys and writes a new self-signed certificate into Cert:\LocalMachine\Remote Desktop.[4]
Does Network Level Authentication (NLA) Cause the RDP Internal Error?
Network Level Authentication (NLA) requires the client to authenticate against the server via CredSSP before a secure desktop connection is initialized. If domain controllers are unreachable, or if the server’s cryptographic ciphers reject the client’s handshake, NLA fails silently and triggers the generic internal error.
Step 5: Adjusting SecurityLayer and UserAuthentication in the Windows Registry
You can resolve encryption negotiation deadlocks by setting the security layer to Negotiate mode (SecurityLayer = 1), which permits the client and server to dynamically agree on the highest mutually supported TLS or RDP encryption tier.[2]
Execute the following PowerShell commands in an elevated console on the remote host:
$RdpPath = 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'
# Set SecurityLayer: 0 = RDP Native, 1 = Negotiate (Recommended), 2 = Strict TLS
Set-ItemProperty -Path $RdpPath -Name "SecurityLayer" -Value 1 -Type DWord
# Temporarily set UserAuthentication (NLA): 0 = Disabled, 1 = Required
Set-ItemProperty -Path $RdpPath -Name "UserAuthentication" -Value 0 -Type DWord
# Ensure Minimum Encryption Level is set to Client Compatible (Level 2)
Set-ItemProperty -Path $RdpPath -Name "MinEncryptionLevel" -Value 2 -Type DWord
Disabling NLA (UserAuthentication = 0) should serve as a temporary diagnostic step to restore emergency administrative access. Once network connectivity is confirmed and underlying certificate stores are repaired, re-enable NLA (UserAuthentication = 1) to shield port 3389 against unauthenticated denial-of-service and brute-force attacks.
Step 6: Restarting Remote Desktop Services via PowerShell Console
Apply registry modifications immediately by restarting the core Terminal Services stack:
Restart-Service -Name TermService -Force
To confirm the service is listening on port 3389 with the updated configuration:
Get-NetTCPConnection -LocalPort 3389 -State Listen | Select-Object LocalAddress, LocalPort, OwningProcess
Organizations hosting remote enterprise infrastructure in local data centers can eliminate latency-induced handshake drops by utilizing dedicated infrastructure such as Dedicated Servers in Pakistan, which offer single-digit round-trip network performance and dedicated physical hardware.
Production Verification and Connection Validation Checklist
Execute this checklist sequentially to confirm complete resolution and prevent regression:
- DNS and IP Resolution Verified: Ping or run
Test-NetConnection -ComputerName <Target_IP> -Port 3389from the client workstation. - Client Cache Evicted: Purged
%LOCALAPPDATA%\Microsoft\Terminal Server Client\Cacheand deleted storedTERMSRV/credentials viacmdkey. - Audio Redirection Disabled: Set Remote Audio Playback to “Do not play” in
mstsc.exeoptions. - MachineKeys Permissions Validated: Confirmed
icacls "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys"grantsBUILTIN\Administrators:(F)andEveryone:(R,W). - Certificate Bound to Listener: Verified that
Cert:\LocalMachine\Remote Desktopholds a valid, non-expired certificate. - SecurityLayer Configured: Checked that
HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\SecurityLayeris set to1(Negotiate). - Event Viewer Channels Monitored: Inspected
Applications and Services Logs > Microsoft > Windows > TerminalServices-RemoteConnectionManager > Operationalfor clean session establishment logs.
Deploy High-Performance Cloud VPS and Dedicated Servers with NextGen
Tired of connection freezes, protocol errors, and latency bottlenecks? NextGen provides enterprise-grade Windows Server VPS and dedicated bare-metal infrastructure optimized for low-latency remote desktop operations.
Explore Enterprise Dedicated ServersDisclaimer: This post is for informational and educational purposes only, accurate to the best of our knowledge at publication. It does not constitute advice. We do not guarantee accuracy or completeness and accept no liability for any decisions or losses resulting from reliance on this content.
Sources & Official References
- Microsoft Learn. "Troubleshoot Remote Desktop disconnected errors." Official Technical Guidance. Retrieved November 2026. https://learn.microsoft.com/en-us/troubleshoot/windows-server/remote/troubleshoot-remote-desktop-disconnected-errors
- Microsoft Learn. "Terminal Services RDP-Tcp Configuration Settings and SecurityLayer Registry Reference." Technical Documentation. Retrieved November 2026. https://learn.microsoft.com/en-us/troubleshoot/windows-server/remote/rdp-security-layer
- Microsoft Learn. "Event ID 36870: A fatal error occurred when attempting to access the TLS server credential private key." Schannel Diagnostics. Retrieved November 2026. https://learn.microsoft.com/en-us/troubleshoot/windows-server/identity/schannel-event-36870
- Microsoft Learn. "Default permissions for the MachineKeys directories." Windows Security Documentation. Retrieved November 2026. https://learn.microsoft.com/en-us/troubleshoot/windows-server/windows-security/default-permissions-machinekeys-folders
- Microsoft TechNet / Support Archive. "Remote Desktop connection freezes or disconnects with internal error when audio redirection is enabled." Retrieved November 2026. https://learn.microsoft.com/en-us/troubleshoot/windows-server/remote/remote-desktop-audio-redirection-issues
- RFC 1191. "Path MTU Discovery." Internet Engineering Task Force (IETF). Retrieved November 2026. https://datatracker.ietf.org/doc/html/rfc1191
