The "Connection reset by peer" error in rdesktop typically occurs when the remote server terminates the connection abruptly. This can happen due to various reasons ranging from network issues to server-side configurations.
- When connecting to Windows Server 2016/2019 with default security settings
- During high-latency network connections
- When the remote desktop session host is overloaded
- With certain NLA (Network Level Authentication) configurations
First, increase verbosity to get more detailed logs:
rdesktop -v -d domain -u username -p password remote.server.com
Check for these specific patterns in the output:
ERROR: recv: Connection reset by peer
Connection established using SSL.
ERROR: recv: Connection reset by peer
Solution 1: Disable NLA temporarily
rdesktop -u username -p password -x m -g 90% -a 16 remote.server.com
Solution 2: Use older RDP protocol version
rdesktop -u username -p password -4 -a 16 remote.server.com
Solution 3: Adjust encryption level
rdesktop -u username -p password -E -a 16 remote.server.com
For persistent issues, modify the ~/.rdesktop/config file:
[common]
username=your_username
password=your_password
domain=your_domain
clientname=linux_client
bitmap_cache=yes
bitmap_cache_persist=yes
compression=yes
encryption=yes
nla=no
If the issue persists across multiple servers:
- Check MTU settings with:
ping -M do -s 1472 server.com
- Test with different ports:
rdesktop server.com:3389
- Verify firewall rules aren't dropping packets mid-session
When rdesktop proves unreliable:
# FreeRDP alternative
xfreerdp /u:username /p:password /v:server.com +fonts /dynamic-resolution
Or Remmina with this configuration profile:
[remmina]
name=Server RDP
protocol=RDP
server=server.com
username=user
password=secret
security=nla
resolution=1280x720
The "Connection reset by peer" error in rdesktop typically occurs when the remote Windows host terminates the RDP session unexpectedly. This can happen due to various reasons ranging from network issues to server-side configurations.
From my experience administering Linux systems, these are the most frequent causes:
- Server-side Group Policy restrictions
- Network firewall interrupting the connection
- Outdated rdesktop version with protocol incompatibilities
- SSL/TLS handshake failures
- Session limit reached on Windows host
First, enable verbose output to get more details:
rdesktop -v -d domain -u username server.example.com
The '-v' flag provides detailed connection logs that often reveal the exact point of failure.
Try these protocol adjustments:
rdesktop -a 16 -z -x l -r sound:off -g 1280x1024 remote_host
Where:
- -a 16: Forces 16-bit color depth
- -z: Enables compression
- -x l: Uses LAN-like performance tuning
On the Windows host, verify these settings:
# PowerShell command to check RDP settings Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name 'fDenyTSConnections'
Also confirm network-level authentication isn't blocking the connection.
If issues persist, consider these alternatives:
# Using FreeRDP (more modern implementation) xfreerdp /v:server.example.com /u:username /p:password /cert:ignore
Check both local and remote firewalls. For Linux:
sudo ufw status verbose sudo iptables -L -n -v
Some Windows servers require specific RDP protocol versions:
rdesktop -4 -k en-us remote_host # Force RDP4 protocol rdesktop -5 -k en-us remote_host # Force RDP5 protocol
For recurring issues, create a wrapper script with retry logic:
#!/bin/bash MAX_RETRIES=3 COUNT=0 while [ $COUNT -lt $MAX_RETRIES ]; do rdesktop -a 16 -z -x m -g 1024x768 remote_host if [ $? -eq 0 ]; then exit 0 fi ((COUNT++)) sleep 5 done exit 1