Open Source API Gateway

400 Bad Request: Request Body Could Not Be Read

Membrane API Gateway returns 400 Bad Request with a link to this page when the echo plugin cannot read the request body the client sent. The body is incomplete or broken, so the gateway rejects the request.

The Error Response

The response contains the status 400, the problem type https://membrane-api.io/problems/user and a link to this page. The type user means that the client or the network between the client and the gateway caused the problem. The request had no Content-Encoding, so this is not a decompression problem. The status stays 400 even when the body is first read in the response flow.

Common Causes

The Body Ended Too Early

The client closed the connection or stopped sending before the body was complete. With a Content-Length header, the detail reads Body ended N bytes before the declared length of M ….

Broken Chunked Encoding

A request with Transfer-Encoding: chunked has malformed chunks or ends before the final chunk.

An I/O Error on the Client Connection

Another network error occurred while the body was being read. The detail field carries the root cause message.

How to Fix It

  1. Client: send the complete body with a Content-Length that matches it, or with valid chunked framing.
  2. Client: do not close the connection before the request is sent.
  3. Operator: check the network path from the client, for example a proxy or load balancer in front of Membrane that cuts off request bodies.

Hide Details in Production

By default, Membrane runs in development mode and adds details to error responses that help you find the problem. These details may reveal information about your setup. In production, turn them off:

configuration:
production: true
configuration:
  production: true

Add the configuration document to your apis.yaml and separate it from the APIs with ---.

Related Documentation

Configuration reference:

← All Membrane error messages

Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.