've been having problems transferring files over a pretty bad connection (I'm trying to upload a file on a cloud server) via rsync.

The rsync essentially hangs after about a minute or so. This is the way I'm trying to perform the upload:

rsync -avz --progress -e "ssh" ~/target.war root@my-remote-server:~/

There is no error message or other info. It simply hangs displaying something like:

7307264  14%   92.47kB/s    0:07:59

Ping-ing the remote endpoint doesn't seem to be loosing packages as far as I see.

My local machine is a Mac.

Any help on how to overcome this problem would be nice. Thank you.

  • Have you tried using "--partial" flag and adding KeepAlives to your SSH: unix.stackexchange.com/a/68813/24379? BTW, the downvote wasn't mine. Sep 8, 2014 at 13:42
  • Thank you for the idea. Yes, tried both, seems nothing changed. As a sidenote, my ssh_config is oddly located in /etc/ssh_config, not in /etc/ssh/ssh_config as the man page describes it.. Anyway, tried with explicit config file and still hangs. Sep 8, 2014 at 13:56
  • Have you tried using scp or sftp to transfer the file? Is rsync saving enough time on the transfer to be worth the trouble?
    – Kenster
    Sep 9, 2014 at 11:29
  • What's "pretty bad" about the connection (other than the rsync problem)? You say ping is working. What other problems are you having? Try scp with the -v option. Maybe it will give you some details on what's going on. Aug 18, 2016 at 2:50

2 Answers 2


Try it without the -z option, you could add -C to the ssh command if you must have compression (otherwise the -e ssh part is not needed as that's the default).


As we cannot know the cause of connection problems, I can suggest the --partial option of rsync. It simply is able to restart an interrupted download/upload.

By default, rsync will delete any partially transferred file if the transfer is interrupted. In some circumstances it is more desirable to keep partially transferred files. Using the --partial option tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster.

If you want to avoid the possibility of long hanging of connection, you can use the --timeout option:

This option allows you to set a maximum I/O timeout in seconds. If no data is transferred for the specified time then rsync will exit. The default is 0, which means no timeout.

I prefer mixing these two options, re-iterating the upload/download when I catch the return code nonzero from the rsync command.

Some example rsync return codes:

 23     Partial transfer due to error
 24     Partial transfer due to vanished source files
 30     Timeout in data send/receive  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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