# nginx: [emerg] the "server_names_hash_bucket_size" directive value is too small

- **ID:** `nginx/name-too-long-buffer-overflow`
- **Domain:** nginx
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

The configured server_names_hash_bucket_size is insufficient for the length of server names defined, causing hash table bucket overflow.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| nginx/1.18.0 | active | — | — |
| nginx/1.20.0 | active | — | — |
| nginx/1.24.0 | active | — | — |
| nginx/1.26.0 | active | — | — |

## Workarounds

1. **Increase server_names_hash_bucket_size to at least 128 in the http block: `http { server_names_hash_bucket_size 128; ... }`** (90% success)
   ```
   Increase server_names_hash_bucket_size to at least 128 in the http block: `http { server_names_hash_bucket_size 128; ... }`
   ```
2. **If the error persists, double the value (e.g., 256) and reload: `http { server_names_hash_bucket_size 256; }`** (85% success)
   ```
   If the error persists, double the value (e.g., 256) and reload: `http { server_names_hash_bucket_size 256; }`
   ```
3. **Shorten long server names or use wildcards (e.g., *.example.com instead of very-long-subdomain.example.com) to reduce name length.** (75% success)
   ```
   Shorten long server names or use wildcards (e.g., *.example.com instead of very-long-subdomain.example.com) to reduce name length.
   ```

## Dead Ends

- **** — 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. (70% fail)
- **** — The error is configuration-specific; removing names only avoids the symptom, not the root cause, and names must be re-added eventually. (50% 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. (60% fail)
