Can you please make sure the following is present in your /etc/ssh/sshd_config
Subsystem sftp internal-sftp
Match group sftponly
Additionally, Often SFTP error arises when ssh is not properly installed on the server. So, when you try to connect to SFTP server it always gives error “ssh: connect to host x.x.x.x port 22: Connection refused“.
In Linux servers, we check and make sure that SSH is installed properly by executing the command
dpkg --get-selections | grep ssh
If there is an error, then we install it correctly by running the command:
apt-get install openssh-server
Finally, we restart the service and ensure that the user could connect to SFTP server without any failure.