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

Advertisement

RyanWeir
Joined:
Posts:
2

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

Hi,

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?

Thanks
  • CSharpCode.JPG (75.21 KB, Private file)
Description: C# code
  • sessionLog.jpg (215.1 KB, Private file)
Description: Session log
  • SFTPVersion.JPG (21.57 KB, Private file)
Description: SFTP server version

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

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.

Reply with quote

RyanWeir
Joined:
Posts:
2

Attached are the logs.
  • sessionlog_5.7.4_GUI.log (7.52 KB, Private file)
Description: Session log for GUI
  • sessionlog_5.7.4.log (3.96 KB, Private file)
Description: Session log for .NET assembly

Reply with quote

martin
Site Admin
martin avatar

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).

Reply with quote

Advertisement

You can post new topics in this forum