kubernetes/kops · error

failed to find network %q

Error message

failed to find network %q

What it means

The Hetzner Cloud API responded successfully to client.Get for the network, but returned nil — meaning no network matching the given ID or name exists in the project. kOps throws this only when the task had an explicit ID set (v.ID != nil), because a missing network is then a hard failure rather than 'needs to be created'.

Source

Thrown at upup/pkg/fi/cloudup/hetznertasks/network.go:67

	return v.ID
}

func (v *Network) Find(c *fi.CloudupContext) (*Network, error) {
	cloud := c.T.Cloud.(hetzner.HetznerCloud)
	client := cloud.NetworkClient()

	idOrName := fi.ValueOf(v.Name)
	if v.ID != nil {
		idOrName = fi.ValueOf(v.ID)
	}

	network, _, err := client.Get(context.TODO(), idOrName)
	if err != nil {
		return nil, fmt.Errorf("failed to find network %q: %w", idOrName, err)
	}
	if network == nil {
		if v.ID != nil {
			return nil, fmt.Errorf("failed to find network %q", idOrName)
		}
		return nil, nil
	}

	matches := &Network{
		Name:      v.Name,
		Lifecycle: v.Lifecycle,
		ID:        new(strconv.FormatInt(network.ID, 10)),
	}

	if v.ID == nil {
		matches.IPRange = network.IPRange.String()
		matches.Labels = network.Labels
		matches.Region = v.Region
		for _, subnet := range network.Subnets {
			if subnet.IPRange != nil {
				matches.Region = string(subnet.NetworkZone)
				matches.Subnets = append(matches.Subnets, subnet.IPRange.String())

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify the configured network ID with `hcloud network list` in the correct project and update the cluster spec.
  2. Remove the explicit ID so kOps creates a new network, or create the network manually first.
  3. Confirm the API token belongs to the project that contains the network.
  4. If the network was deleted intentionally, run `kops update cluster` to recreate infrastructure.

Example fix

// before
network:
  id: "9999999"  # deleted network
// after
network:
  id: "1234567"  # existing network ID from `hcloud network list`
Defensive patterns

Strategy: validation

Validate before calling

out, err := exec.Command("hcloud", "network", "describe", cfg.NetworkID).Output()
if err != nil {
	return fmt.Errorf("network %q does not exist in this Hetzner project: %w", cfg.NetworkID, err)
}

Prevention

When it happens

Trigger: Find in upup/pkg/fi/cloudup/hetznertasks/network.go:67: client.Get returns no error but network == nil while v.ID is set — i.e. the configured network ID does not exist in the Hetzner project the token can access.

Common situations: Network was deleted manually in the Hetzner console; cluster config references a network from another project; stale/typo'd network ID after reusing a cluster spec; token scoped to the wrong project.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/5a072a03b3e2912f. Report an issue: GitHub.