# HTTP 411 Length Required — Meaning, Causes & Fixes

> The server refuses the request because it has no Content-Length header.

411 means the server wants to know the size of the body up front and won't accept a request without `Content-Length` — for example one sent with chunked transfer encoding. It mostly comes from older servers, some proxies, and endpoints that must know the size before accepting data.

- Class: 4xx Client Error
- Retry: No — change the request first
- Cacheable by default: no
- Defined in: [RFC 9110 §15.5.12 — 411 Length Required](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.12)

## Example response

```http
HTTP/1.1 411 Length Required
Content-Type: application/json
Content-Length: 27

{"error":"Length Required"}
```

## Common causes

- A POST or PUT sent with chunked transfer encoding to a server that doesn't support it.
- An empty-body POST sent without `Content-Length: 0`.

## How to fix it

1. Send `Content-Length`, including `Content-Length: 0` for empty bodies.
2. Buffer the body before sending if your client streams it in chunks.

## Send a 411 from your server

### Express

```
res.status(411).json({ error: "Length Required" });
```

### Next.js route handler

```
return Response.json({ error: "Length Required" }, { status: 411 });
```

### Flask

```
return {"error": "Length Required"}, 411
```

### Go net/http

```
http.Error(w, "Length Required", http.StatusLengthRequired)
```

### nginx

```
return 411;
```

## FAQ

### Why does my empty POST get 411?

Some servers and proxies require Content-Length even when there's no body. Send Content-Length: 0 or an explicit empty body.

## Related status codes

- [413 Content Too Large](https://www.devkult.com/http/413.md)
- [400 Bad Request](https://www.devkult.com/http/400.md)
- [417 Expectation Failed](https://www.devkult.com/http/417.md)

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