# upstream sent too big header while reading response header from upstream, client: 10.0.0.1, server: example.com, upstream: "http://127.0.0.1:8080"

- **ID:** `nginx/proxy-buffer-size-too-small`
- **Domain:** nginx
- **Category:** protocol_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

The upstream server's response headers exceed the default proxy_buffer_size (4KB), causing nginx to reject the response with a 502 error.

## 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 proxy_buffer_size to 8K or larger (e.g., 16K) in the location or server block: `proxy_buffer_size 16k;`** (95% success)
   ```
   Increase proxy_buffer_size to 8K or larger (e.g., 16K) in the location or server block: `proxy_buffer_size 16k;`
   ```
2. **Also increase proxy_buffers to match for consistency: `proxy_buffers 8 16k;`** (90% success)
   ```
   Also increase proxy_buffers to match for consistency: `proxy_buffers 8 16k;`
   ```
3. **If the large header is due to many cookies, consider using a custom header compression or reducing cookie size at the application level as a long-term fix.** (70% success)
   ```
   If the large header is due to many cookies, consider using a custom header compression or reducing cookie size at the application level as a long-term fix.
   ```

## Dead Ends

- **** — proxy_buffers controls the number and size of buffers for the response body, not the initial header buffer. (70% fail)
- **** — proxy_buffering off affects body buffering, not header buffering; the header buffer size is always limited by proxy_buffer_size. (60% fail)
- **** — While this can fix the symptom, it requires application changes that may break features like session management or authentication. (40% fail)
