Console9

Rsync: error in rsync protocol data stream

Fix the Rsync 'error in rsync protocol data stream (code 12)' caused by disk space issues, version mismatches, network drops, and SSH problems.

Rsync produces the "error in rsync protocol data stream (code 12)" message when the data stream between the sender and receiver is corrupted, interrupted, or incompatible.

When Rsync Produces This Error

Rsync produces "error in rsync protocol data stream (code 12)" during a file transfer when the connection between the source (sender) and destination (receiver) breaks unexpectedly. The error appears as:

rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.2.7]

Rsync also produces this error when the remote server runs out of disk space during the transfer. The receiver cannot write incoming data, which corrupts the protocol data stream.

Rsync triggers this error when the local and remote Rsync versions are incompatible. A major version mismatch causes the sender and receiver to disagree on the protocol format, leading to data stream corruption.

What Causes the "error in rsync protocol data stream" in Rsync

Rsync uses a custom binary protocol to coordinate data transfer between the sender and receiver processes. Code 12 indicates that the data stream was corrupted, truncated, or unreadable. Multiple conditions cause this protocol failure.

Rsync fails with code 12 when the destination disk fills up during the transfer. The receiver process cannot complete file writes, and the resulting I/O error propagates back through the protocol stream. Rsync surfaces this as a protocol data stream error rather than a disk space error.

Rsync fails with code 12 when an SSH connection drops mid-transfer due to network instability, firewall timeouts, or SSH idle disconnects. The sender or receiver detects the broken pipe and reports the protocol error. Slow connections over high-latency links are particularly susceptible to this failure.

Rsync fails with code 12 when the remote machine does not have Rsync installed. SSH connects successfully, but the remote shell cannot find the rsync binary. The remote shell's error output (such as "command not found") enters the protocol stream and corrupts it.

Rsync fails with code 12 when the compression ( -z) flag triggers a bug in certain version combinations. Rsync versions between 3.2.4 and 3.2.5 on some distributions exhibit compression-related protocol errors, particularly when the sender and receiver use different compression libraries.

How to Fix "error in rsync protocol data stream" in Rsync

  1. Check disk space on the remote machine.Verify that the destination has sufficient free space for the entire transfer.

    ssh user@203.0.113.10 "df -h /home/user/dest/"

    Rsync requires enough free space on the destination to hold the largest single file being transferred, plus space for temporary files. Free up disk space or expand the partition if the filesystem is full.

  2. Verify that Rsync is installed on the remote machine.SSH into the remote server and run Rsync to confirm it is available.

    ssh user@203.0.113.10 "rsync --version"

    Rsync must be installed on both the local and remote machines. Install Rsync on the remote machine if it is missing. See How to Install Rsync.

  3. Match Rsync versions on both machines.Compare the Rsync version on the local and remote systems.

    rsync --version
    ssh user@203.0.113.10 "rsync --version"

    Rsync versions should be within 1-2 minor versions of each other. Update Rsync on both machines to the latest available version.

    === "Ubuntu / Debian"

    sudo apt update && sudo apt install --only-upgrade rsync

    === "CentOS / Fedora / RHEL"

    sudo dnf update rsync
  4. Check SSH connectivitybetween the local and remote machines before diagnosing the Rsync protocol error. Verify that SSH connects without errors.

    ssh user@203.0.113.10 "echo connection successful"

    Rsync depends on a stable SSH connection for remote transfers. Resolve any SSH authentication or connectivity issues before retrying the Rsync transfer.

  5. Remove the compression flagif the error occurs with -z enabled. Rsync compression has known compatibility issues between certain version pairs.

    rsync -av /home/user/src/ user@203.0.113.10:/home/user/dest/

    Rsync transfers data without compression. If this resolves the error, the compression feature is the cause.

  6. Add SSH keepalive settingsto prevent idle connection timeouts during long transfers.

    rsync -avz -e "ssh -o ServerAliveInterval=60 -o ServerAliveCountMax=3" /home/user/src/ user@203.0.113.10:/home/user/dest/

    Rsync passes SSH keepalive options that send a null packet every 60 seconds and allow 3 missed keepalives before disconnecting.

  7. Check destination folder permissions.Verify that the SSH user owns the destination directory and has write access.

    ssh user@203.0.113.10 "ls -la /home/user/dest/"

    Change ownership if needed:

    ssh user@203.0.113.10 "sudo chown -R user:user /home/user/dest/"
  8. Use verbose modeto identify the exact point of failure. Rsync's verbose output shows which file was being transferred when the error occurred.

    rsync -avvz /home/user/src/ user@203.0.113.10:/home/user/dest/

    Multiple -v flags increase verbosity. Look for "read error: Connection reset by peer" (network drop) or "write error: No space left on device" (disk full) in the output.

How to Verify the Fix

Rsync completes the transfer without the protocol data stream error when the underlying cause is resolved. Run the transfer and verify clean output.

rsync -avz /home/user/src/ user@203.0.113.10:/home/user/dest/

Rsync prints the file list and a summary line showing total bytes sent and received without error messages. Verify the destination with ls -la on the remote server.

Edge Cases and Variations

Rsync produces code 12 on Windows Subsystem for Linux (WSL) when using the Windows-native SSH with the Cygwin Rsync binary. The SSH and Rsync binaries must come from the same environment. Install the Cygwin SSH client or use the WSL SSH client with the WSL Rsync binary.

Rsync produces code 12 when the remote SSH host key has changed. The SSH connection fails with "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" and the error propagates as a protocol data stream error. Remove the old host key with ssh-keygen -R 203.0.113.10 and reconnect.

Rsync produces code 12 when a firewall between the client and server drops idle TCP connections. Configure SSH keepalive settings or add --timeout=600 to the Rsync command to detect and recover from dropped connections. See Rsync transfer hangsfor detailed firewall and timeout fixes.

Rsync: failed to set permissions on-- destination permission problems are one cause of protocol data stream errors on non-Unix filesystems.

Rsync: failed to set times on-- timestamp permission failures can accompany protocol data stream errors during the same transfer.

Rsync transfer hangs-- network timeouts and SSH idle disconnects cause both hanging transfers and protocol data stream errors.