For an SFTP connection to a Windows Server 2022 host, ECONNREFUSED - Connection refused by server usually means the server is not accepting the connection on the target port.
Use this checklist:
- Verify the server is using SFTP, not FTP/FTPS.
- In FileZilla, the protocol must be SFTP - SSH File Transfer Protocol.
- SFTP normally uses port 22.
- Confirm the OpenSSH Server service is running on Windows Server.
- If the OpenSSH Server service does not start, or SFTP connections hang, validate the configuration with:
sshd -t - Also review Event Viewer for related events.
- If the OpenSSH Server service does not start, or SFTP connections hang, validate the configuration with:
- Check the OpenSSH configuration.
- In
sshd_config, make sure the following entry is present and correctly formatted:Subsystem sftp sftp-server.exe - Make sure there are no trailing spaces or invalid entries in
sshd_config.
- In
- Restart the OpenSSH Server service after any config change.
NET STOP "OpenSSH SSH Server" && NET START "OpenSSH SSH Server" - Enable SFTP logging to capture the refusal cause.
- Edit
%ProgramData%\ssh\sshd_config - Set:
SyslogFacility LOCAL0 LogLevel DEBUG3 - Add or update:
Subsystem sftp sftp-server.exe -f LOCAL0 -l DEBUG3 - Restart the service.
- Then review logs in
%ProgramData%\ssh\logs.
- Edit
- If authentication is failing after connection starts, check key and permission settings.
- For key-based auth, store admin keys in
C:\ProgramData\ssh\administrators_authorized_keysand verify permissions. - If the server refuses the key, add:
PubkeyAcceptedKeyTypes +ssh-rsa HostKeyAlgorithms +ssh-rsa - Restart the OpenSSH Server service after making the change.
- For key-based auth, store admin keys in
- If transfers start and then abort, check permissions on the SFTP directories.
- Make sure
ChrootDirectorypoints to a local directory, not a UNC path. - Make sure
SYSTEM/Administratorsowns the chroot directory. - Make sure each user has a writable directory inside the chroot, but does not have write permission on the chroot directory itself.
- Use
icaclsin an elevated Command Prompt to verify and repair NTFS permissions.
- Make sure
The ECONNABORTED after transferring part of the file suggests the connection was established and then dropped during transfer. In that case, the most relevant checks are:
- OpenSSH service health
-
sshd_configvalidity - SFTP subsystem entry
- Event Viewer
- SFTP logging
- NTFS/chroot permissions