# HTTP 431 Request Header Fields Too Large — Meaning, Causes & Fixes

> The request's headers — often its cookies — are too large for the server.

431 (RFC 6585) means the request's headers, in total or a single one, exceed the server's limit. Cookies are the usual suspect: every cookie for a domain rides along on every request, and analytics, A/B testing and auth cookies add up until a limit — commonly 8 to 16 KB — is crossed. Node.js's default maximum header size is 16 KB.

- Class: 4xx Client Error
- Retry: No — change the request first
- Cacheable by default: no
- Defined in: [RFC 6585 §5 — 431 Request Header Fields Too Large](https://www.rfc-editor.org/rfc/rfc6585#section-5)

## Example response

```http
HTTP/1.1 431 Request Header Fields Too Large
Content-Type: application/json
Content-Length: 43

{"error":"Request Header Fields Too Large"}
```

## Common causes

- Too many or too large cookies — especially on localhost, where every project's cookies pile up.
- Huge JWTs packed with claims in the `Authorization` header.
- Proxies adding large forwarding headers.

## How to fix it

1. Clear the site's cookies (on localhost this fixes most cases).
2. Keep tokens small: store session data server-side and send a reference.
3. Raise the limit if needed: Node `--max-http-header-size`, nginx `large_client_header_buffers`.

## Send a 431 from your server

### Express

```
res.status(431).json({ error: "Request Header Fields Too Large" });
```

### Next.js route handler

```
return Response.json({ error: "Request Header Fields Too Large" }, { status: 431 });
```

### Flask

```
return {"error": "Request Header Fields Too Large"}, 431
```

### Go net/http

```
http.Error(w, "Request Header Fields Too Large", http.StatusRequestHeaderFieldsTooLarge)
```

### nginx

```
return 431;
```

## FAQ

### Why do I get 431 on localhost?

Every app you've run on localhost shares one cookie jar for that host, so cookies accumulate. Clear them in DevTools → Application → Cookies.

### Is nginx's 'Request Header Or Cookie Too Large' the same problem?

Yes, though nginx reports it as a 400 with that message rather than 431. The fix is the same: shrink cookies or raise large_client_header_buffers.

## Related status codes

- [413 Content Too Large](https://www.devkult.com/http/413.md)
- [414 URI Too Long](https://www.devkult.com/http/414.md)
- [400 Bad Request](https://www.devkult.com/http/400.md)

Open the interactive page: https://www.devkult.com/http/431