caddyserver/caddy · error
opening input file: %v
Error message
opening input file: %v
What it means
cmdImportStorage ('caddy storage import') failed at os.Open of the --input file (unless '-' was passed for stdin). The wrapped error is a standard os.PathError: usually 'no such file or directory' or 'permission denied'. Nothing has been imported yet at this point.
Source
Thrown at cmd/storagefuncs.go:105
if err != nil {
return caddy.ExitCodeFailedStartup, err
}
stor, err = val.(caddy.StorageConverter).CertMagicStorage()
if err != nil {
return caddy.ExitCodeFailedStartup, err
}
} else {
stor = caddy.DefaultStorage
}
// setup input
var f *os.File
if importStorageCmdImportFile == "-" {
f = os.Stdin
} else {
f, err = os.Open(importStorageCmdImportFile)
if err != nil {
return caddy.ExitCodeFailedStartup, fmt.Errorf("opening input file: %v", err)
}
defer f.Close()
}
// store each archive element
tr := tar.NewReader(f)
for {
hdr, err := tr.Next()
if err == io.EOF {
break
}
if err != nil {
return caddy.ExitCodeFailedQuit, fmt.Errorf("reading archive: %v", err)
}
b, err := io.ReadAll(tr)
if err != nil {
return caddy.ExitCodeFailedQuit, fmt.Errorf("reading archive: %v", err)View on GitHub (pinned to 50e54ee279)
Solutions
- Verify the path exists and is readable: ls -l <input.tar>
- Use an absolute path for --input to avoid cwd ambiguity
- Fix permissions/ownership or copy the file to a location the invoking user can read
- To stream from another command, pass --input - and pipe the tar in
Example fix
# before caddy storage import --config caddy.json --input backup.tar # error: opening input file: open backup.tar: no such file or directory # after caddy storage import --config caddy.json --input /var/backups/caddy/storage.tar
Defensive patterns
Strategy: validation
Validate before calling
INPUT=/var/backups/caddy/storage.tar
[ -r "$INPUT" ] || { echo "missing/unreadable: $INPUT"; exit 1; }
file "$INPUT" # should report: POSIX tar archive (not gzip!) Prevention
- Use absolute paths for --input
- Pre-check readability with test -r before scripted imports
- Keep export archives uncompressed plain tar to match the importer
When it happens
Trigger: Passing a wrong path to --input; passing a gzip-compressed archive is fine here (path opens) but a missing/unreadable file triggers this; relative path resolved from the wrong cwd; input file owned by another user.
Common situations: Importing a storage tar produced on another server with a typo'd path; running caddy as a service user without read access to /root/backup.tar; SELinux denying read of a file in /tmp.
Related errors
- opening output file: %v
- checking if default Caddyfile exists: %v
- reading default Caddyfile: %v
- retrieving current executable permission bits: %v
- resolving current executable symlink: %v
AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15).
Data as JSON: /api/errors/fa3e2866edd5bd36.
Report an issue: GitHub.