Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Any luck

Hi, were you able to fix the issue?

Re: Remote side unexpectedly closed network connection

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=C:\path\to\winscp.log command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Remote side unexpectedly closed network connection


I am running the latest version of WinSCP (5.17.2) on both a Windows Server and a Windows 10 PC.

I have a batch file which has been working perfectly until recently and now fails every time it runs.

The script is very simple: It connects to a server, it checks for new files in a directory, it then exits

I capture the exit code of the above script to identify if files were found (If files were found then '1' is returned otherwise the script successfully closes and exits from winscp and '0' is returned).

The problem that I am having is the when the connection is closed / exited an error message is received every time and an exit code of 1 is ALWAYS returned. The error states "Remote side unexpectedly closed network connection".

This has only recently started occurring. I do not have access to the SFTP server, but I am getting good support from the SFTP server owner. They are not seeing any issues at their end. I am able to reproduce the issue using the GUI and have attached a screenshot of the issue.

Whilst writing this post, I have decided to revert the version of WinSCP back to 5.15.9. This has now resolved the issue I was experiencing! Something has changed with more recent versions. I hope the developers can review this post and provide me with an update if possible.