lionsoul2014/ip2region · error

ip2region search failed for IPv6 address

Error message

ip2region search failed for IPv6 address

What it means

nginx runtime warning: xdb_search failed for a native IPv6 address after copying the 16 address bytes into the v6 searcher; the underlying v6 lookup returned an error (corrupt index or bad searcher state) and the variable is simply not set rather than failing the request.

Source

Thrown at binding/nginx/src/ngx_http_ip2region_module.c:456

                        ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
                                      "ip2region search failed for IPv4-mapped IPv6 address");
                    }
                }
            } else {
                // 处理纯IPv6地址
                if (ip2region_conf->v6_searcher != NULL) {
                    searcher_ptr = &ip2region_conf->v6_searcher->searcher;
                    bytes_ip_t ip6_bytes[16];
                    if (p != NULL) {
                        memcpy(ip6_bytes, p, 16);
                        err = xdb_search(searcher_ptr, ip6_bytes, 16, &region);
                        if (err == 0) {
                            v->data = (unsigned char *)region.value;
                            v->len = strlen(region.value);
                            xdb_region_buffer_free(&region);
                            return NGX_OK;
                        } else {
                            ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
                                          "ip2region search failed for IPv6 address");
                        }
                    }
                } else {
                    ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
                                  "no IPv6 searcher available for IPv6 address");
                }
            }
            break;

#endif

    }
    // 如果搜索失败,释放 region buffer
    xdb_region_buffer_free(&region);

    ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
                  "ip2region: no region found for IP address");

View on GitHub (pinned to c1a1fc7d59)

Solutions

  1. Verify the v6 xdb file and reload nginx so searchers are rebuilt
  2. Check nginx error logs for the root cause of repeated failures
  3. Keep the variable optional in templates so an unset value does not break responses
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at binding/nginx/src/ngx_http_ip2region_module.c:456 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of lionsoul2014/ip2region@c1a1fc7d59 (2026-09-02). Data as JSON: /api/errors/e833448e4da7ad5c. Report an issue: GitHub.