{"record":{"id":"e833448e4da7ad5c","repo":"lionsoul2014/ip2region","slug":"ip2region-search-failed-for-ipv6-address","errorCode":null,"errorMessage":"ip2region search failed for IPv6 address","messagePattern":"ip2region search failed for IPv6 address","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"binding/nginx/src/ngx_http_ip2region_module.c","lineNumber":456,"sourceCode":"                        ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,\n                                      \"ip2region search failed for IPv4-mapped IPv6 address\");\n                    }\n                }\n            } else {\n                // 处理纯IPv6地址\n                if (ip2region_conf->v6_searcher != NULL) {\n                    searcher_ptr = &ip2region_conf->v6_searcher->searcher;\n                    bytes_ip_t ip6_bytes[16];\n                    if (p != NULL) {\n                        memcpy(ip6_bytes, p, 16);\n                        err = xdb_search(searcher_ptr, ip6_bytes, 16, &region);\n                        if (err == 0) {\n                            v->data = (unsigned char *)region.value;\n                            v->len = strlen(region.value);\n                            xdb_region_buffer_free(&region);\n                            return NGX_OK;\n                        } else {\n                            ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,\n                                          \"ip2region search failed for IPv6 address\");\n                        }\n                    }\n                } else {\n                    ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,\n                                  \"no IPv6 searcher available for IPv6 address\");\n                }\n            }\n            break;\n\n#endif\n\n    }\n    // 如果搜索失败，释放 region buffer\n    xdb_region_buffer_free(&region);\n\n    ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,\n                  \"ip2region: no region found for IP address\");","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/nginx/src/ngx_http_ip2region_module.c#L438-L474","documentation":"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.","triggerScenarios":"Thrown at binding/nginx/src/ngx_http_ip2region_module.c:456 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the v6 xdb file and reload nginx so searchers are rebuilt","Check nginx error logs for the root cause of repeated failures","Keep the variable optional in templates so an unset value does not break responses"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1","analyzedAt":"2026-09-02T16:58:39.988Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}