Rsync: error in rsync protocol data stream

How to fix protocol data stream error from Rsync.

There are multiple causes for the "Error in Rsync Protocol Data Stream" error:

rsync error: error in rsync protocol data stream (code 12)

The remote machine disk is full

Check that the remote machine disk is not full and the transfer will not occupy the disk at its full capacity.

Rsync is not installed on the remote machine

Log into the remote machine and run rsync to make sure it's installed:

$ rsync

Remote destination doesn't exist

Check that the remote destination folder exists.

Do a quick test:

$ rsync FILE USER@HOST:/my_existing_directory/

Remote destination folder permissions

Check the permissions of the destination folder The user running the Rsync command should own the destination folder:

$ chown -R username /destination_folder

Rsync versions not in sync

Verify that both the local machine and remote machine are running the latest version of Rsync:

$ rsync --version

Idle connection

Use the -timeout option during a Rsync transfer.

Similarly, you can configure the remote machine SSH parameters around KeepAlive, ServerAliveInterval, ServerAliveCountMax to prevent a timeout.