Post a reply

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


I'd say that the UserCustomServices account does not have an access to network allowed.

Try to run the code using the same account you use for GUI (Administrator).

Attached are the logs.

Re: Cannot connect to SFTP server via .Net (Network error: Connection refused), but using GUI works

Please attach a full (unobfuscated) session log file showing the problem along with log of a working GUI session (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. 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.

Cannot connect to SFTP server via .Net (Network error: Connection refused), but using GUI works


There is a SFTP server I need to connect to, using username and password. I can connect to it using the GUI, but I cannot using the .Net assembly. I get a 'Network error: Connection refused'. Attached should be all the relevant information. The SFTP server is only using SFTP-3, so I even tried using SessionOptions.AddRawSettings("SFTPMaxVersion", "3");. The SFTP owners say they do see successes in their logs, but only when I use the GUI. The failures come up as using port 21. My logs do show that after SFTP fails, it knocks the FTP port. They don't state at what point it fails, and my logs do not show this either.

Any suggestions to fix this?