{"record":{"id":"3fe90951f6bf0493","repo":"kubernetes/kops","slug":"cannot-find-dns-zone-q-please-pre-create-the-zo","errorCode":null,"errorMessage":"cannot find DNS Zone %q.  Please pre-create the zone and set up NS records so that it resolves","messagePattern":"cannot find DNS Zone %q\\.  Please pre-create the zone and set up NS records so that it resolves","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/dns.go","lineNumber":75,"sourceCode":"\t\treturn nil, fmt.Errorf(\"error getting DNS zones provider\")\n\t}\n\n\tzones, err := zonesProvider.List()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing DNS zones: %v\", err)\n\t}\n\n\tvar matches []dnsprovider.Zone\n\tfindName := strings.TrimSuffix(cluster.Spec.DNSZone, \".\")\n\tfor _, zone := range zones {\n\t\tid := zone.ID()\n\t\tname := strings.TrimSuffix(zone.Name(), \".\")\n\t\tif id == cluster.Spec.DNSZone || name == findName {\n\t\t\tmatches = append(matches, zone)\n\t\t}\n\t}\n\tif len(matches) == 0 {\n\t\treturn nil, fmt.Errorf(\"cannot find DNS Zone %q.  Please pre-create the zone and set up NS records so that it resolves\", cluster.Spec.DNSZone)\n\t}\n\n\tif len(matches) > 1 {\n\t\tklog.Infof(\"Found multiple DNS Zones matching %q, please set the cluster's spec.dnsZone to the desired Zone ID:\", cluster.Spec.DNSZone)\n\t\tfor _, zone := range zones {\n\t\t\tid := zone.ID()\n\t\t\tklog.Infof(\"\\t%s\", id)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"found multiple DNS Zones matching %q\", cluster.Spec.DNSZone)\n\t}\n\n\tzone := matches[0]\n\treturn zone, nil\n}\n\nfunc validateDNS(cluster *kops.Cluster, cloud fi.Cloud) error {\n\tif !cluster.PublishesDNSRecords() || cluster.UsesPrivateDNS() {\n\t\tklog.V(2).Infof(\"Skipping DNS validation for non-public DNS\")","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/dns.go#L57-L93","documentation":"findZone matches zones by ID or name (trailing dot trimmed) against cluster.Spec.DNSZone. If no provider zone matches, kOps throws this error because the cluster's DNS records cannot be hosted. DNS zones must be pre-created and delegated (NS records) before cluster creation/validation can proceed.","triggerScenarios":"validateDNS or precreateDNS with spec.dnsZone set to a zone that does not exist in the DNS account — typo in zone name, zone in a different AWS account/region-agnostic account, or zone simply never created.","commonSituations":"Forgetting to pre-create a Route53/Cloud DNS/Azure DNS public zone; zone exists in another cloud account/subscription than the credentials in use; using the DNS name instead of zone ID where matching failed due to delegation issues.","solutions":["Pre-create the DNS zone (e.g. `aws route53 create-hosted-zone --name example.com ...` or via cloud console)","Set spec.dnsZone (or --dns-zone) to the exact zone name or ID that exists in the account your credentials point to","Confirm NS records delegate the zone so it resolves publicly","Verify you are authenticated to the account that actually hosts the zone"],"exampleFix":"// before\nkops create cluster --dns-zone clusters.nonexistent.example ...\n// after\naws route53 create-hosted-zone --name clusters.example.com --caller-reference 1\nkops create cluster --dns-zone clusters.example.com ...","handlingStrategy":"validation","validationCode":"// Ensure zone exists and is resolvable before kops create\nif _, err := net.LookupNS(cluster.Spec.DNSZone); err != nil {\n    return fmt.Errorf(\"zone %s not resolvable: pre-create it and set NS records\", cluster.Spec.DNSZone)\n}","typeGuard":null,"tryCatchPattern":"if _, err := findZone(cluster, cloud); err != nil {\n    if strings.Contains(err.Error(), \"cannot find DNS Zone\") {\n        return precreateZoneAndNSRecords(cluster.Spec.DNSZone)\n    }\n    return err\n}","preventionTips":["Pre-create hosted zones before `kops create cluster`","Delegate with NS records so the zone resolves publicly","Authenticate to the account that actually hosts the zone"],"tags":["dns","zone-not-found","configuration","route53"],"backgroundTag":"dns-zone-not-found","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}