nginx
config_error
ai_generated
true
nginx: [emerg] the "server_names_hash_bucket_size" directive value is too small
ID: nginx/name-too-long-buffer-overflow
90%Fix Rate
85%Confidence
1Evidence
2024-02-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| nginx/1.18.0 | active | — | — | — |
| nginx/1.20.0 | active | — | — | — |
| nginx/1.24.0 | active | — | — | — |
| nginx/1.26.0 | active | — | — | — |
Root Cause
The configured server_names_hash_bucket_size is insufficient for the length of server names defined, causing hash table bucket overflow.
generic中文
配置的 server_names_hash_bucket_size 不足以容纳定义的服务器名称长度,导致哈希表桶溢出。
Official Documentation
https://nginx.org/en/docs/http/ngx_http_core_module.html#server_names_hash_bucket_sizeWorkarounds
-
90% success Increase server_names_hash_bucket_size to at least 128 in the http block: `http { server_names_hash_bucket_size 128; ... }`
Increase server_names_hash_bucket_size to at least 128 in the http block: `http { server_names_hash_bucket_size 128; ... }` -
85% success If the error persists, double the value (e.g., 256) and reload: `http { server_names_hash_bucket_size 256; }`
If the error persists, double the value (e.g., 256) and reload: `http { server_names_hash_bucket_size 256; }` -
75% success Shorten long server names or use wildcards (e.g., *.example.com instead of very-long-subdomain.example.com) to reduce name length.
Shorten long server names or use wildcards (e.g., *.example.com instead of very-long-subdomain.example.com) to reduce name length.
中文步骤
在 http 块中将 server_names_hash_bucket_size 增加到至少 128:`http { server_names_hash_bucket_size 128; ... }`如果错误仍然存在,将值加倍(例如 256)并重新加载:`http { server_names_hash_bucket_size 256; }`缩短长服务器名称或使用通配符(例如 *.example.com 替代 very-long-subdomain.example.com)以减少名称长度。
Dead Ends
Common approaches that don't work:
-
70% fail
server_names_hash_max_size sets the total hash size, while bucket size controls per-bucket alignment; max_size without increasing bucket_size still causes overflow for long names.
-
50% fail
The error is configuration-specific; removing names only avoids the symptom, not the root cause, and names must be re-added eventually.
-
60% fail
The value must be a power of two (e.g., 32, 64, 128, 256) to align with CPU cache lines; non-power-of-two values are ignored or cause other errors.