ipfs/kubo · critical
peer ID invalid: %s
Error message
peer ID invalid: %s
What it means
The PeerID string in Identity.PeerID exists but fails peer.Decode — it is not a valid multihash/base58 peer ID. Node construction aborts because every libp2p component depends on a decodable identity.
Source
Thrown at core/node/groups.go:281
finalBstore,
)
}
// Identity groups units providing cryptographic identity
func Identity(cfg *config.Config) fx.Option {
// PeerID
cid := cfg.Identity.PeerID
if cid == "" {
return fx.Error(errors.New("identity was not set in config (was 'ipfs init' run?)"))
}
if len(cid) == 0 {
return fx.Error(errors.New("no peer ID in config! (was 'ipfs init' run?)"))
}
id, err := peer.Decode(cid)
if err != nil {
return fx.Error(fmt.Errorf("peer ID invalid: %s", err))
}
// Private Key
if cfg.Identity.PrivKey == "" {
return fx.Options( // No PK (usually in tests)
fx.Provide(PeerID(id)),
fx.Provide(libp2p.Peerstore),
)
}
sk, err := cfg.Identity.DecodePrivateKey("passphrase todo!")
if err != nil {
return fx.Error(err)
}
return fx.Options( // Full identity
fx.Provide(PeerID(id)),View on GitHub (pinned to 329838acdf)
Solutions
- Restore the original Identity.PeerID (and matching PrivKey) from backup
- Re-init the repo (`ipfs init`) if the identity is unrecoverable — note this generates a new peer identity
- Trim whitespace/newlines around the PeerID value and verify it decodes (e.g. `ipfs id <peerID>` validates a peer ID)
Example fix
// before (config.json)
"Identity": { "PeerID": "12D3KooW...\n " }
// after
"Identity": { "PeerID": "12D3KooWAbcdefghijklmnopqrstuvwxyzExample" } Defensive patterns
Strategy: validation
Validate before calling
if _, err := peer.Decode(cfg.Identity.PeerID); err != nil {
return fmt.Errorf("Identity.PeerID is not a valid peer ID: %w", err)
} Try / catch
if _, err := peer.Decode(peerIDStr); err != nil {
// restore from backup or re-init
return fmt.Errorf("invalid peer ID in config: %w", err)
} Prevention
- Never hand-edit the PeerID value; copy the whole string exactly
- Trim whitespace when copying peer IDs between systems
- Keep PeerID and PrivKey paired when restoring backups
When it happens
Trigger: `peer.Decode(cfg.Identity.PeerID)` returns an error — malformed base58, wrong length, truncated CID, or non-peer-ID content pasted into PeerID.
Common situations: Hand-editing config.json and corrupting the PeerID; copying an ID with whitespace or line-wrap; pasting a libp2p key or CID instead of a peer ID; partial restore of a config backup.
Related errors
- private network does not work with Routing.Type=auto. Update
- Provide.Strategy='flat' is no longer supported. Use 'all' in
- invalid configuration: Provide.DHT.MaxWorkers cannot be 0 wh
- Routing.Type=delegated does not support content providing. S
- serveHTTPGateway: invalid gateway address: %q (err: %s)
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/e2b5cbc6e1847230.
Report an issue: GitHub.