coredns/coredns · error

unexpected failure looking up database %q schema %q: %v

Error message

unexpected failure looking up database %q schema %q: %v

What it means

During newGeoIP the plugin probes each candidate schema (City, ASN) by querying the database. If the probe returns an error that is not geoip2.InvalidMethodError (the sentinel for 'schema not provided'), something unexpected failed while reading the database and startup aborts with this wrapped error including the db filename and schema name.

Source

Thrown at plugin/geoip/geoip.go:61

	reader, err := geoip2.Open(dbPath)
	if err != nil {
		return nil, fmt.Errorf("failed to open database file: %v", err)
	}
	db := db{Reader: reader}
	schemas := []struct {
		provides int
		name     string
		validate func() error
	}{
		{name: "city", provides: city, validate: func() error { _, err := reader.City(probingIP); return err }},
		{name: "asn", provides: asn, validate: func() error { _, err := reader.ASN(probingIP); return err }},
	}
	// Query the database to figure out the database type.
	for _, schema := range schemas {
		if err := schema.validate(); err != nil {
			// If we get an InvalidMethodError then we know this database does not provide that schema.
			if _, ok := err.(geoip2.InvalidMethodError); !ok {
				return nil, fmt.Errorf("unexpected failure looking up database %q schema %q: %v", filepath.Base(dbPath), schema.name, err)
			}
		} else {
			db.provides |= schema.provides
		}
	}

	if db.provides == 0 {
		return nil, fmt.Errorf("database does not provide any supported schema (city, asn)")
	}

	return &GeoIP{db: db, edns0: edns0}, nil
}

// ServeDNS implements the plugin.Handler interface.
func (g GeoIP) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
	return plugin.NextOrFailure(pluginName, g.Next, ctx, w, r)
}

View on GitHub (pinned to 558c9757a9)

Solutions

  1. Re-download the MaxMind database from a trusted source and replace the file.
  2. Verify file integrity (checksum) after download.
  3. Confirm the file is not truncated (compare file size with the published size).
  4. Test the db with a minimal geoip2 reader program to confirm it can be queried.
Defensive patterns

Strategy: fallback

Validate before calling

r, err := geoip2.Open(dbPath)
if err == nil {
    if _, err := r.Country(netip.MustParseAddr("8.8.8.8")); err != nil && !errors.Is(err, geoip2.InvalidMethodError{}) {
        return fmt.Errorf("db probe failed: %w", err)
    }
}

Try / catch

if _, ok := err.(geoip2.InvalidMethodError); !ok {
    return fmt.Errorf("corrupt db %s: %w", dbPath, err)
} // otherwise treat as schema-not-provided and continue

Prevention

When it happens

Trigger: A corrupt or truncated mmdb file, a database whose search-tree/data sections are damaged, or an incompatible/corrupt mmdb version causing lookup errors other than InvalidMethodError during validation.

Common situations: Partially downloaded or interrupted database updates; an encrypted or renamed non-mmdb file that still opens; disk corruption.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of coredns/coredns@558c9757a9 (2026-09-06). Data as JSON: /api/errors/4d621f7f71ec5825. Report an issue: GitHub.