ipfs/kubo · error
API file too large, must be <2048 bytes long: %s
Error message
API file too large, must be <2048 bytes long: %s
What it means
Reading $IPFS_PATH/api (the file tracking the daemon's RPC address) hit the deliberate 2048-byte cap: the file is read through a LimitReader as a safety measure, and reaching exactly 2048 bytes means it is not a sane API file (corrupted or planted).
Source
Thrown at repo/fsrepo/fsrepo.go:370
}
return nil, err
}
defer f.Close()
// read up to 2048 bytes. io.ReadAll is a vulnerability, as
// someone could hose the process by putting a massive file there.
//
// NOTE(@stebalien): @jbenet probably wasn't thinking straight when he
// wrote that comment but I'm leaving the limit here in case there was
// some hidden wisdom. However, I'm fixing it such that:
// 1. We don't read too little.
// 2. We don't truncate and succeed.
buf, err := io.ReadAll(io.LimitReader(f, 2048))
if err != nil {
return nil, err
}
if len(buf) == 2048 {
return nil, fmt.Errorf("API file too large, must be <2048 bytes long: %s", apiFilePath)
}
s := string(buf)
s = strings.TrimSpace(s)
return ma.NewMultiaddr(s)
}
func (r *FSRepo) Keystore() keystore.Keystore {
return r.keystore
}
func (r *FSRepo) Path() string {
return r.path
}
// SetAPIAddr writes the API Addr to the /api file.
func (r *FSRepo) SetAPIAddr(addr ma.Multiaddr) error {
// Create a temp file to write the address, so that we don't leave empty file when theView on GitHub (pinned to 329838acdf)
Solutions
- Delete the stale 'api' file in the repo directory and restart (or let the daemon rewrite it)
- Check nothing is writing garbage into $IPFS_PATH/api
- Re-run with a fresh IPFS_PATH if the repo is untrusted
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at repo/fsrepo/fsrepo.go:370 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/2ce39758691ceaf0.
Report an issue: GitHub.