I’m using the WinSCP application to connect to my SFTP server.
I can connect and upload/download files successfully when using the WinSCP application included in the download, but when I try to connect via SmartConnect scripting per this blog article, it fails with the error:
WinSCP.SessionRemoteException: Network error: Connection to “xxxx.com” refused.
Make sure that you are connecting to the correct port in your code.
In the code example, port 2222 is being used:
.PortNumber = 2222
Make sure to modify this to use the same port that you see the WinSCP application connect successfully. Very often port 22 is the correct number but it can be any value the host system has set it to.