An SFTP upload can appear to work for most of its duration and then fail at the end. The file may be nearly complete—or even visible in the destination directory—while the client reports an error. That usually means the connection was established successfully, but the server could not finish writing, close, or rename the file.
The useful distinction is between transport failures and destination failures. A dropped network connection points toward the former. A permission error, full filesystem, or failed rename points toward the latter. Check the evidence before retrying a large upload or changing server permissions.
First, identify what actually failed
Record the exact error, the destination path, the approximate time, and whether the failure happens with every file or only large ones. If possible, try a small test file in the same destination directory. A successful small upload suggests the account and basic directory access work, but does not rule out quotas, space limits, or size-related timeouts.
Use OpenSSH’s command-line client to get a second view of the transfer:
sftp -v deploy@example.net
Then try a deliberately named test upload:
sftp> put probe.txt incoming/probe.txt
Verbose output can clarify whether the client lost its connection or received an SFTP status error. It does not, by itself, reveal every server-side cause. For a Linux OpenSSH server, check the SSH service logs around the failure time. The relevant log location varies by distribution and logging configuration; common places include the system journal and authentication logs.
Check the destination, not just the login
An account can authenticate and list a directory while still being unable to create files there. Check the destination’s ownership and permissions as the server administrator:
namei -l /srv/uploads/incoming
ls -ld /srv/uploads /srv/uploads/incoming
namei -l shows permissions for each component of the path. The account needs search permission on parent directories and write plus search permission on the directory where it creates files. A writable parent does not imply that a nested upload directory is writable.
If the account is restricted to an SFTP chroot, check the chroot rules too. With OpenSSH’s ChrootDirectory, the chroot directory and its parent components must be owned by root and must not be writable by the restricted user. A common pattern is to keep the chroot root-owned and create a separate writable subdirectory inside it. Don’t make the chroot writable as a shortcut; fix ownership and access on the intended upload directory instead. The Linux OpenSSH SFTP setup guide covers the server-side configuration and chroot model.
Look for space and quota limits
A file can fail near completion when the filesystem runs out of free space. Check the filesystem containing the destination, not just the root filesystem:
df -h /srv/uploads
df -i /srv/uploads
The first command checks available storage; the second checks available inodes. A filesystem can have free bytes but no inodes left to create another file. Also investigate user, group, project, or hosting-provider quotas when ordinary filesystem space looks healthy.
Do not assume that a failed upload left no data behind. Inspect the destination for a partial file, but confirm the filename and timestamp before removing anything. A similarly named file may be a previous valid upload.
Treat temporary files and renames separately
Some clients upload to a temporary name and rename the file only after the transfer finishes. This helps avoid exposing a partially written file under its final name, but it adds another operation that can fail. The account may be allowed to create files in one directory but not rename them there, or the temporary and final paths may be on different filesystems.
Test creation and renaming in the intended destination using the same account. With shell access, an administrator can check the directory’s permissions and filesystem layout; don’t grant shell access just to run a test if the account is meant to be SFTP-only. If a client offers an option to upload directly to the final name, understand the tradeoff: readers may see an incomplete file while it is being written.
For deployments, a safer pattern is to upload to a unique temporary filename in the same directory as the final file, verify it, then rename it into place. A same-filesystem rename is generally atomic from the perspective of processes opening the destination, whereas copying across filesystems is not. Coordinate this with the application: replacing an active file can still affect processes that read it in multiple steps.
Separate client behavior from server behavior
If one client fails, retry with another SFTP client or OpenSSH’s sftp command before changing server settings. Check whether the client is using a different remote path, transfer mode, temporary-file strategy, or filename encoding. A path that looks like /uploads in a graphical client may be interpreted relative to the account’s SFTP root rather than the server’s actual filesystem root.
For graphical workflows, the SFTP client comparison can help you choose a tool with the diagnostics and transfer controls you need. If the server is Windows, confirm that the account’s filesystem permissions allow creation and renaming in the destination; the Windows OpenSSH SFTP server guide explains the relationship between SFTP access and filesystem permissions.
A focused troubleshooting order
When an upload fails, work through these checks in order:
- Capture the exact client error and determine whether the SSH connection dropped.
- Retry a small file in the same directory.
- Check directory traversal, write permissions, and chroot restrictions.
- Check free space, inodes, and applicable quotas.
- Inspect server logs and any partial or temporary file.
- Test the client’s rename behavior and compare with another client.
This sequence avoids the risky “make everything writable” fix. It also helps pinpoint whether the failure is in the network, the server’s storage limits, the account’s access, or the final rename.
I'm building ShadeTerm — an SSH client that organizes terminals, SFTP, code editing, and server tools into workspaces.
Top comments (0)