SOLVED: sftp Error: Connection timed out after 20 seconds of inactivity

Error: Connection timed out after 20 seconds of inactivity


I just want to share a peculiar sftp connectivity issue that we encountered recently and how we solved it.

This is the message we got when trying to connect to the server using sftp and obviously it failed to retrieve directory listing.

Status: Connecting to mydomain.com...
Response: fzSftp started, protocol_version=8
Command: keyfile "somefile.ppk"
Command: open "user@mydomain.com" 22
Error: Connection timed out after 20 seconds of inactivity
Error: Could not connect to server

We usually connect to my remote server using sftp to upload and download the work files.

All was well till yesterday, when suddenly, the connectivity to the server was not happening, the network error showed connection timed out.

We distinctly remember being able to connect till sometime back, before the above error cropped up suddenly.

We were breaking our heads as to why the connection was not happening.

Rolled back in time and evaluated the things that we did during the past hours. It was suddenly that we got a brainwave that solved the problem.

The explanation:

It occurred to us that we had just enabled the CDN for the server. You know what the CDN (Cloudflare, Cloudfront etc are CDNs) does. It obfuscates the real IP address of the domain and replaces it with a different IP address.

So, the sftp was trying to connect to one of the CDN's IP addresses, which resulted in the "Connection timed out after 20 seconds of inactivity".

To put it simply, what was happening was that the request to mydomain.com was resolving to the IP address of the CDN.

The Solution:

So, we then created a sub-domain and kept it outside the CDN and used that name instead of the domain name.

Alternately, you can also use the real IP address of your server.

Simple solution, but till you get the hang of it, it is a real blood boiler.

That, in short is how we solved the failed connection attempt "sftp Error Connection timed out after 20 seconds of inactivity" problem. SOLVED.

No comments:

Imagen 3: A New Era of AI Image Creation?

  Google has just unveiled Imagen 3, the latest iteration of their Gemini AI. They're making bold claims about enhanced image quality, ...

Most Popular

Copyrighted.com Registered & Protected DWYE-NHTO-NBNH-7FFM