ipfs/kubo · error

can't combine --all with other matching options

Error message

can't combine --all with other matching options

What it means

This error comes from the `ipfs p2p close` command pre-run validation in kubo. The `--all` flag closes every active p2p stream/listener, so it is mutually exclusive with the selective filters `--peer`, `--listen`, and `--target`. The command refuses to run when both styles of matching are combined because the intent would be ambiguous.

Source

Thrown at core/commands/p2p.go:537

			listen, err = ma.NewMultiaddr(listenOpt)
			if err != nil {
				return err
			}
		}

		if t {
			target, err = ma.NewMultiaddr(targetOpt)
			if err != nil {
				return err
			}
		}

		if !(closeAll || p || l || t) {
			return errors.New("no matching options given")
		}

		if closeAll && (p || l || t) {
			return errors.New("can't combine --all with other matching options")
		}

		match := func(listener p2p.Listener) bool {
			if closeAll {
				return true
			}
			if p && proto != listener.Protocol() {
				return false
			}
			if l && !listen.Equal(listener.ListenAddress()) {
				return false
			}
			if t && !target.Equal(listener.TargetAddress()) {
				return false
			}
			return true
		}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Remove the `--all` flag if you want to filter by peer/listen/target address.
  2. Remove the `--peer`, `--listen`, and `--target` flags if you truly want to close everything.
  3. Check the output of `ipfs p2p close --help` to confirm which flags are mutually exclusive.
  4. In scripts, branch: build either an `--all` invocation or a filtered invocation, never both.

Example fix

// before
err := exec.Command("ipfs", "p2p", "close", "--all", "--peer", peerID).Run()
// after
err := exec.Command("ipfs", "p2p", "close", "--peer", peerID).Run()
Defensive patterns

Strategy: validation

Validate before calling

flags := map[string]bool{"all": all, "peer": peer != "", "listen": listen != "", "target": target != ""}
if flags["all"] && (flags["peer"] || flags["listen"] || flags["target"]) {
    return errors.New("--all cannot be combined with --peer/--listen/--target")
}

Prevention

When it happens

Trigger: Running `ipfs p2p close --all` while also passing `--peer <peerID>`, `--listen <address>`, or `--target <address>`; e.g. `ipfs p2p close --all --peer Qm...` or a script that appends `--all` to a filter command.

Common situations: Shell scripts that hardcode `--all` as a default flag and then accept user-supplied filters; operators trying to close 'all streams for a given peer' and assuming `--all` scopes the other flags.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/d2ea9c3c53eacb24. Report an issue: GitHub.