When you try to connect an FTP site hosted in IIS, you may come across this error message in Command Prompt: “Connection closed by remote host”.
In a third-party FTP client, this message may show up for the same issue:
Connection failed. FlowSocketConnector: Failed to conect to target address. Windows error 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
The SSH session has been terminated
For the environment I troubleshot, this issue started occurring after migrating the FTP site from Windows Server 2008 to 2016.
Troubleshooting
Since this is a server-side issue, I’d recommend checking the Event Viewer logs first. For the server I worked on, I saw these error messages in Event Viewer:
Event ID 10
An error has occurred: The configuration section ‘system.ftpServer/security/authentication’ cannot be read because it is missing a section declaration
There were two warnings that followed the event above:
Event ID 12
Unable to find schema for config section ‘system.xaml.hosting/httpHandlers’. This section will be ignored
Event ID 12
Unable to find schema for config section ‘system.serviceModel/client’. This section will be ignored
Additionally, IIS Manager showed this error:
There was an error while performing this operation. Filename: applicationHost.config. Error: Cannot add duplicate collection entry of type ‘add’ with combined key attributes ‘users, roles, permissions’ respectively set to ‘*, Read’
Solution for FTP error “Connection closed by remote host”
The root cause of the FTP issue was this missing line in the applicationHost.config file:
<section name="authentication" overrideModeDefault="Deny" />
FTP started working after adding the line.
This line was missing because it didn’t exist in the Windows Server 2008 server. It was there in Windows Server 2016 machine but once the site configuration is migrated using Web Deploy from 2008 to 2016 server, the line was removed.