ipfs/kubo · error
no key by the given name or PeerID was found
Error message
no key by the given name or PeerID was found
What it means
keylookup (called by Publish) searched the node's self key and then every keystore entry, comparing derived peer IDs against the requested target PeerID/Key. When nothing matches, it returns this error: the requested publishing identity does not exist on this node.
Source
Thrown at core/coreapi/name.go:249
// Then, look in the keystore.
for _, key := range keys {
privKey, err := kstore.Get(key)
if err != nil {
return nil, err
}
pid, err := peer.IDFromPrivateKey(privKey)
if err != nil {
return nil, err
}
if targetPid == pid {
return privKey, nil
}
}
return nil, errors.New("no key by the given name or PeerID was found")
}
View on GitHub (pinned to 329838acdf)
Solutions
- Run `ipfs key list` (or KeyAPI.List) and use an exact existing key name or this node's own peer ID.
- Import the key on this node first: `ipfs key import <name> <keyfile>`.
- Verify you are talking to the node that owns the key (check `ipfs id`).
Example fix
// before
api.Name().Publish(ctx, p, options.Key("wrongPeerID"))
// after
keys, _ := api.Key().List(ctx)
// pick an existing key name from keys, e.g. "self" or a generated key
api.Name().Publish(ctx, p, options.Key("publish-key")) Defensive patterns
Strategy: validation
Validate before calling
keys, err := api.Key().List(ctx)
if err != nil {
return err
}
if !slices.ContainsFunc(keys, func(k coreiface.Key) bool { return k.Name() == keyName }) {
return fmt.Errorf("key %q not present on this node", keyName)
} Try / catch
_, err := api.Name().Publish(ctx, p, opts.Key(keyName))
if err != nil && strings.Contains(err.Error(), "no key by the given name") {
return fmt.Errorf("import or generate %q on this node before publishing", keyName)
} Prevention
- List keys on the target node before publishing.
- Import keys with `ipfs key import` when moving between nodes.
- Confirm node identity with `ipfs id` when publishing by PeerID.
When it happens
Trigger: Publishing with a key selector (name or PeerID) that matches no keystore entry and not self, e.g. `ipfs name publish --key=<peerID> ...` for a peer ID this node does not own.
Common situations: Publishing on the wrong node (key exists on another daemon); typo in key name; expecting a remote key to be usable locally; peer ID of an imported-but-since-deleted key.
Related errors
- cannot import key with name 'self'
- cannot create new key: %w
- no key named %s was found
- failed to read config: %w
- no delegated publishers configured: add Ipns.DelegatedPublis
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/d398d6db4637e3e9.
Report an issue: GitHub.