SFTP connections that keep dropping can interrupt file transfers, break automation scripts, and waste time. This guide walks you through the most common causes—network instability, idle timeouts, firewall rules, and server limits—and gives you clear, actionable steps to stabilize your connection. You’ll need access to your client settings, your server configuration, and possibly your firewall or router.
What You’ll Need
- SFTP client (e.g., FileZilla, WinSCP, or command-line
sftp) - Server access (SSH credentials and ability to edit server config files)
- If the server is remote: ability to access its firewall or hosting control panel
- A text editor for config files (like nano or Notepad++)
Step-by-Step
- Check your network stability. A flaky Wi-Fi or overloaded router is the #1 cause of dropped SFTP connections. Run a continuous ping to the server (e.g.,
ping -t yourserver.comon Windows,ping yourserver.comon Mac/Linux) and watch for packet loss or high latency. If you see drops, move to a wired connection, restart your router, or contact your ISP. - Increase the idle timeout in your SFTP client. Many clients disconnect after a period of inactivity. In FileZilla: Edit → Settings → Connection → FTP/SFTP, and set “Timeout in seconds� to a higher value (e.g., 60 or 120). In WinSCP: Session → Advanced → Connection, and increase “Timeout� (default is 15 seconds). For command-line sftp, add
-o ServerAliveInterval=15to keep the connection alive. - Enable keep-alive packets. This sends a small packet periodically to keep the connection open. In FileZilla, under the same settings, check “Send keepalive commands� (or use the “Keep connections alive� checkbox). In WinSCP, under Connection, enable “Keep connection alive� and set an interval (e.g., 30 seconds).
- Adjust SSH server keep-alive settings. On the server, edit
/etc/ssh/sshd_configand add or modify these lines:ClientAliveInterval 30 ClientAliveCountMax 3
This sends a keep-alive every 30 seconds and allows up to 3 missed responses before disconnecting. Then restart SSH:
sudo systemctl restart sshd(orsudo service ssh restart). - Check firewall and NAT timeouts. Firewalls or routers often drop idle connections. If you control the firewall, increase the TCP timeout for established connections (e.g., to 30 minutes or more). If you don’t, using keep-alive (steps 3-4) is the easiest workaround.
- Limit concurrent connections. Some servers limit how many SFTP sessions an IP can have. If you have multiple transfers or scripts running, close unused sessions. Check server logs for “too many connections� errors.
- Use a different transfer mode. If you’re transferring many small files, SFTP can be slow and prone to timeouts. Consider compressing files into a single archive before transfer, or use a tool like rsync over SSH (if available) which resumes interrupted transfers.
- Check server load. A heavily loaded server may drop connections. Monitor CPU/memory usage (e.g.,
toporhtop). If the server is overloaded, consider upgrading or moving transfers to off-peak hours.
Common Mistakes
- Only adjusting client settings, not server. If the server has a low idle timeout, client keep-alive may not help—you need to adjust the server’s
ClientAliveInterval. - Setting keep-alive too aggressively. Sending packets every 1 second can actually cause issues on high-latency links. Stick to 15-60 seconds.
- Ignoring the router’s NAT table. Even with keep-alive, some routers drop connections after a fixed time. You may need to enable “port forwarding� or “DMZ� for the SFTP port (default 22) to avoid NAT timeouts.
- Mistaking SFTP for FTPS. SFTP uses SSH (port 22), not FTP. Don’t change FTP settings; they don’t apply.
Tips
- For automated scripts, always use
sftp -o ServerAliveInterval=15to prevent drops during long transfers. - If you’re behind a corporate firewall, ask the network admin to whitelist your IP and increase idle timeout for port 22.
- Use a VPN if your ISP or network throttles SSH traffic.
- For large transfers, consider using
scporrsyncinstead—they may be more resilient. - Keep your SSH server and client updated to avoid bugs that cause disconnections.
Troubleshooting
If the connection still drops after following the steps:
- Test with a different client. If it works with one client but not another, the issue is client-specific. Check that client’s settings.
- Test from a different network. If it works from your phone’s hotspot but not your home network, the problem is your router or ISP.
- Check server logs. Look at
/var/log/auth.log(Debian/Ubuntu) or/var/log/secure(RHEL/CentOS) for messages like “Connection closed by� or “Timeout�. This will tell you if the server is dropping you or if the network is. - Try a different port. Some networks block port 22. If you can, configure SSH to listen on port 443 or 2222, and test.
- Check for DDoS protection or fail2ban. If your IP gets banned after a few failed attempts, you’ll be disconnected. Check with your hosting provider.
Frequently Asked Questions
Why does my SFTP connection drop after a few minutes of inactivity?
Most likely an idle timeout on either the client or server. Increase the timeout settings and enable keep-alive as described above.
Can I resume an interrupted SFTP transfer?
SFTP itself doesn’t support resume. You need to restart the transfer. For large files, consider using rsync over SSH, which can resume.
Does using a VPN help with SFTP drops?
Sometimes. If your ISP or network is throttling or interfering with SSH traffic, a VPN can bypass that. But if the issue is server-side, a VPN won’t help.
Why does SFTP work on my phone but not on my computer?
Different networks or firewall rules. Your computer might be behind a stricter firewall or have a VPN that interferes. Test with a different network or disable VPN temporarily.
Is there a way to keep the connection alive without changing server config?
Yes, use client-side keep-alive (e.g., ServerAliveInterval). It sends a packet that keeps the connection active, even if the server doesn’t send its own.
How do I know if the server is dropping the connection or my network?
Check server logs for “Timeout� or “Connection closed� messages. If the server logs show a timeout, it’s server-side. If you see packet loss in ping, it’s network.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- DisplayPort vs HDMI: Which Cable Should You Use?
- Soundbar vs 2.1 Speaker System: Which Is Better?
- Mouse Moving on Its Own? Causes & Fixes
- Slack Channels for Construction Projects: Setup Guide
- Surface Won’t Turn On: Quick Fixes1.8 h
- Survive Lava for Brainrot Tier List170 points