caddyserver/caddy · error
syncing downloaded file to device: %v
Error message
syncing downloaded file to device: %v
What it means
After the bytes are written, destFile.Sync() (fsync) fails, meaning the OS could not flush the downloaded binary to stable storage. This signals hardware/filesystem trouble: I/O errors, device full, or the file living on failing storage. The deferred restore brings back the original binary.
Source
Thrown at cmd/packagesfuncs.go:336
func writeCaddyBinary(path string, body *io.ReadCloser, fileInfo os.FileInfo) error {
l := caddy.Log()
destFile, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, fileInfo.Mode())
if err != nil {
return fmt.Errorf("unable to open destination file: %v", err)
}
defer destFile.Close()
l.Info("downloading binary", zap.String("destination", path))
_, err = io.Copy(destFile, *body)
if err != nil {
return fmt.Errorf("unable to download file: %v", err)
}
err = destFile.Sync()
if err != nil {
return fmt.Errorf("syncing downloaded file to device: %v", err)
}
return nil
}
const downloadPath = "https://caddyserver.com/api/download"
type pluginPackage struct {
Version string
Path string
}
func (p pluginPackage) String() string {
if p.Version == "" {
return p.Path
}
return p.Path + "@" + p.Version
}View on GitHub (pinned to 50e54ee279)
Solutions
- Check disk health and space: df -h on the binary's mount, dmesg | grep -i 'i/o error'
- Free space and retry the upgrade
- If storage is genuinely failing, replace it before attempting any upgrade
- Move the binary to reliable local storage and re-run
Defensive patterns
Strategy: validation
Validate before calling
df -h "$(dirname "$(command -v caddy)")" # confirm free space before upgrading
Prevention
- Keep at least a few hundred MB free on the binary's filesystem
- Investigate dmesg I/O errors before trusting upgrades on failing disks
- Avoid placing the binary on flaky network storage
When it happens
Trigger: Disk full exactly at fsync time; failing disk or NFS mount erroring on flush; loop-device/container overlay issues; USB media removed.
Common situations: Small root partitions filling during the ~40MB write; flaky network-attached storage holding /usr/local/bin; failing SSD returning EIO.
Related errors
- retrieving current executable permission bits: %v
- resolving current executable symlink: %v
- backing up current binary: %v
- unable to open destination file: %v
- checking if default Caddyfile exists: %v
AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15).
Data as JSON: /api/errors/dc96e7b137a767cc.
Report an issue: GitHub.