Rclone fails to close unused TCP connections due to "use of closed network connection"

What is the problem you are having with rclone?

We are using rclone to transmit our files to a client's SFTP server. The files were successfully uploaded. But when the TCP connections are closed at the end of the process, "Use of Closed network Connection" error is thrown.

Run the command 'rclone version' and share the full output of the command.

xxxxxxxxxx@xxxxx01:~$ rclone version
rclone v1.67.0

  • os/version: ubuntu 22.04 (64 bit)
  • os/kernel: 5.15.0-86-generic (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.22.4
  • go/linking: static
  • go/tags: none

Which cloud storage system are you using? (eg Google Drive)


The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone --config="/path/to/config/file" ls profile_name:/

A log from the command that you were trying to run

2024/07/08 11:26:00 DEBUG : rclone: Version "v1.67.0" starting with parameters ["rclone" "-vv" "--config=/path/to/config/file" "ls" "lxxxxxxxx:/Fxxxxx"]
2024/07/08 11:26:00 DEBUG : Creating backend with remote "lxxxxxxxx:/Fxxxxx"
2024/07/08 11:26:00 DEBUG : Using config file from "/path/to/config/file"
2024/07/08 11:26:00 DEBUG : sftp://FXXXXXX-DIXXXXX@edi-xxxxx.lxxxxxxxxx.com:22//Fxxxxx: New connection> to "SSH-2.0-FileZillaProEnterpriseServer_1.8.7"
2024/07/08 11:26:00 DEBUG : sftp://FXXXXXX-DIXXXXX@edi-xxxxx.lxxxxxxxxx.com:22//Fxxxxx: Shell type "none" from config
2024/07/08 11:26:00 DEBUG : sftp://FXXXXXX-DIXXXXX@edi-xxxxx.lxxxxxxxxx.com:22//Fxxxxx: Using root directory "/Fxxxxx"
<List of files>
2024/07/08 11:28:27 DEBUG : 13 go routines active
2024/07/08 11:28:27 DEBUG : sftp://FXXXXXX-DIXXXXX@edi-xxxxx.lxxxxxxxxx.com:22//Fxxxxx: Closing 1 unused connections
2024/07/08 11:28:27 Failed to ls: close tcp xxx.xxx.xxx.xxx:58486->xxx.xxx.xxx.xxx:22: use of closed network connection

From the logs, it seemed that the remote SFTP server was too eager to close the unused TCP connections. As the result, when rclone attempted to close these connections, it failed to do so due to "use of closed network connection".

Is there a way to bypass this error and let rclone exit gracefully as this issue gave us a lot of false alarms?

Thank you very much.

I agree with your interpretation.

This error is coming from draining the connection pool. Errors here are useless so I think we can safely ignore them.

Try this

v1.68.0-beta.8050.b98a753f4.fix-sftp-drain on branch fix-sftp-drain (uploaded in 15-30 mins)

1 Like

Hi Nick,

Thank you very much for your reply. I will definitely try this out.

I am wondering if the test is successful, how long shall we expect to wait before this version is officially released.

Thank you.

You can see estimated releases dates here:

If you consider using the latest rolling beta too risky you could build your own rclone version using latest release as a base and only add specific commits you need to fix your issue.

1 Like

Let me know how you get on.

If this works it will go in 1.67.1 or 1.68

Thank you, Nick and Sky. I will update shortly. Thanks.

Hi Nick,
I have tested the beta version, and it worked for us. Hope to see the fix rolled out soon.

Thank you very much.