I tried:

rsync -v -v -e 'ssh -p YY' ./testfile me@XXXXX:/home

Error Message

opening connection using: ssh -p YY -l me rsync ->-server -vvve.s . /home 
[sender] make_file(testfile,*,0)
send_file_list done
send_files starting
server_recv(2) starting pid=17537
rsync: connection unexpectedly closed (9 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600)[sender=3.0.6]
_exit_cleanup(code=12, file=io.c, line=600): about to call exit(12)

This works fine:

ssh -p YY me@XXXXX

Which suggests to me the problem is neither that sshd is not running nor that port YY is firewalled. I have checked anyway.

What other problems could there be?

EDIT: The problem seems to have been "self resolving." I could not replicate the following day. I started my local computer up. Perhaps notably I had a different IP address than last time. And now rsync magically works. I'd appreciate guesses as to what it could have been in light of it going away.

  • 1
    Do you have write permission at /home of the remote server? – souravc May 18 '15 at 3:53
  • Sure. When I ssh I can start doing cat and touch etc. On second thought I' not sure what you mean by remote. I'm talking about calling rsync while on a remote server to move things locally. I should have write permissions in both the original and destination folder – user3391229 May 18 '15 at 22:07
  • I've been getting this error (while trying to rsync my Pelican blog to my server) every once in a while. I find that if I ssh into the server, then try the rsync again, it works fine. Not sure what happens in between. – Anthony C Oct 5 '18 at 21:32
  • Not having enough space on the remote server can also raise this error. – Makan Feb 1 '19 at 21:55

You can also get this error if you specify a remote path that doesn't exist.

I got this error on OS X:

$ rsync -avz public/ static:apps/myapp.com
building file list ... done
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/io.c(453) [sender=2.6.9]

Turned it was simply a matter of mistyping the destination path. The apps dir didn't exist. When I changed that to static:sites/myapp.com instead (the sites dir did exist), the error went away.

It's fine if the final directory in the path doesn't exist (I could do static:sites/mynewapp.com) but it appears any preceding directory must already exist.

| improve this answer | |
  • I've almost forgotten asking this question. I haven't had the same problem since. I suspect that this is what happened. – user3391229 Jan 6 '16 at 20:03
  • 1
    also if you don't have rsync executable, it shows similar error. Mostly I have seen in ansibles – mannoj Nov 18 '16 at 6:13
  • For some reason I thought rsync would create the directory if it didn't exist... I guess not - you need to create the destination directory first. If the destination path ends in a slash the directory must exist. If it does not end in a slash, the one level above it must exist. – squarecandy Aug 6 '17 at 20:22
  • I had permission related problem on my remove server... – Chirag Purohit Apr 24 '18 at 13:53
  • 2
    My problem is: remote disk is full. – Zhang Buzz May 29 '19 at 2:40

I got this error when rsync wasn't installed on the target host. The error message in my case also said rsync: command not found. A simple

sudo apt-get install rsync

on the target host solved the problem.

| improve this answer | |
  • I had the a code 12 error and no message about the rsync command not being found. Once installed the error went away. – Hbar Sep 12 '19 at 1:15
  • Please don't response things that have nothing to do with the reason for the question, much less when they don't even have to do with it – abkrim Mar 15 at 15:28

Does your login script at the remote end produce garbage on stdout? Check this with

ssh -p YY me@XXXXX /bin/true > out.txt

If out.txt contains data, identify the offending statements in your .profile or .bashrc and wrap them in

if [ ! -t 1 ]; then
  echo garbage
| improve this answer | |
  • Nada in out.txt. But I also tried that this afternoon during a period where I could not reproduce problem. – user3391229 May 18 '15 at 22:04
  • I tried this at a time when I could produce the problem and I also got nothing in out.txt. – joshreesjones Oct 14 '15 at 15:12

You may need to put in the full path to the ssh binary, ie

rsync -v -v -e '/usr/bin/ssh -p YY' ./testfile me@XXXXX:/home

Though there are other possible causes.

| improve this answer | |
  • Yeah I read that could happen when you have multiple instances of ssh that you could be referencing. However, the fact that it went away the next day makes this unlikely – user3391229 May 18 '15 at 22:05

This error can also happen if the path to rsync at the remote system is not what the local system assumes it to be. You can see what is happening by specifying -vv (or even more vs). If this is the problem you can specify the remote path to rsync with the --rsync-path option.

| improve this answer | |

I was seeing this error:

rsync -e 'ssh -v'

debug1: Exit status 11


rsync error: error in rsync protocol data stream (code 12) at /BuildRoot

I was able to ssh into the remote host and found that it was out of disk space.

| improve this answer | |

I got this error in rsync protocol data stream (code 12) for a pair of rsync's with different versions. So please check the rsync versions on both client and server.

In my case, local rsync was version 2.6.9 (on Mac OSX), while remote one was version 3 (can't remember now the exact version). Once I upgraded my local rsync to version 3 (using brew), the problem was fixed.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.