netbirdio/netbird · error

check chain exists

Error message

check chain exists: %w

What it means

ChainExists failed while checking whether the NetBird raw chain is present in cleanupNoTrackChain. Because cleanup runs at Close, the failure is logged-or-returned depending on rawSupported; when raw was never initialized the error is deliberately swallowed.

Solutions

  1. Verify iptables works at all in the environment
  2. If it fails at shutdown, a reboot or manual 'iptables -t raw -F' clears leftovers
  3. Address CAP_NET_ADMIN or backend issues on the host
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at client/firewall/iptables/manager_linux.go:625 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/ac6ecd72d84769c2. Report an issue: GitHub.

Appendix: source

Thrown at client/firewall/iptables/manager_linux.go:625

			log.Debugf("delete output jump rule: %v", delErr)
		}
		if delErr := m.ipv4Client.DeleteChain(tableRaw, chainNameRaw); delErr != nil {
			log.Debugf("delete orphan chain: %v", delErr)
		}
		return fmt.Errorf("add prerouting jump rule: %w", err)
	}

	m.rawSupported = true
	return nil
}

func (m *Manager) cleanupNoTrackChain() error {
	exists, err := m.ipv4Client.ChainExists(tableRaw, chainNameRaw)
	if err != nil {
		if !m.rawSupported {
			return nil
		}
		return fmt.Errorf("check chain exists: %w", err)
	}
	if !exists {
		return nil
	}

	jumpRule := []string{"-j", chainNameRaw}

	if err := m.ipv4Client.DeleteIfExists(tableRaw, chainOUTPUT, jumpRule...); err != nil {
		return fmt.Errorf("remove output jump rule: %w", err)
	}

	if err := m.ipv4Client.DeleteIfExists(tableRaw, chainPREROUTING, jumpRule...); err != nil {
		return fmt.Errorf("remove prerouting jump rule: %w", err)
	}

	if err := m.ipv4Client.ClearAndDeleteChain(tableRaw, chainNameRaw); err != nil {
		return fmt.Errorf("clear and delete chain: %w", err)
	}

View on GitHub (pinned to 93e97f4bf1)