> ## Content Index
> Fetch the complete content index at: https://datajutsu.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# gRPC's 4MB Message Limit Is on the Wire Bytes (and the Send Side Has No Limit)
- URL: https://datajutsu.com/grpc-4mb-message-limit/
- Published: 2026-10-30T01:29:09.000Z
- Updated: 2026-10-30T01:29:09.000Z
- Author: Data Jutsu

Everyone knows gRPC has a four megabyte message limit, and almost nobody has checked where it actually sits. I put a real grpc-js server and client on the box, pushed payloads of measured sizes through both doors, and read the source to see where the number is enforced. It is not where the config docs make it sound, and the two sides of the connection do not even share the same default.

The defaults are not equal. The send side starts unlimited, and the receive side starts at four megabytes. I sent an eight megabyte request on a stock client with no options at all and it went out fine, but a stock client will refuse to accept a response bigger than four megabytes. Out of the box you can send more than you can read. In the source the constants are right next to each other, one set to negative one which means unlimited and one set to four times a thousand times a thousand times two to the fourth, and both the client and the server read those same two defaults for their own receive and send.

The cap counts the wire bytes, not the size of the value in your head. I binary searched for the exact boundary and it does not land on a round number, because the check runs on the encoded message, and the length prefix that sits in front of a field is a varint that costs more bytes the bigger the value is. A message whose string field is four million one hundred ninety four thousand two hundred ninety five bytes encodes to exactly four million one hundred ninety four thousand three hundred four on the wire and passes. Add one byte to that field, it encodes to four million one hundred ninety four thousand three hundred five, and it is rejected. So the usable payload is a few bytes under four megabytes, and how many bytes under depends on your field layout and how large the values are, which is why you will see the limit trip at different payload sizes in different schemas.

When it trips, the error is code eight, RESOURCE\_EXHAUSTED, and the message names both numbers. On the receive side it reads Received message larger than max with the measured size and the limit side by side, so the one byte you were over is right there in the string. The send side uses a different sentence, Attempted to send message with a size larger than the cap, but it is the same code eight. That is the useful part of the failure. The reason text carries the actual and the limit together, so you are not guessing, you can read exactly how far past the line you went.

The knobs are channel options on the client and options on the server, grpc.max\_receive\_message\_length and grpc.max\_send\_message\_length, and setting either one to negative one turns that side off. With the client receive cap set to negative one an eight megabyte response comes back whole. That is how you move a big payload across, you raise the cap on the side that is receiving. And because the client and the server each enforce their own independent number, you usually have to raise it in both places, the client channel and the server, or the call will still fail on whichever side you forgot.

One more thing that is easy to get wrong. The check runs per message, not per call. A streaming reply is decoded one frame at a time, so a stream of five five megabyte messages dies on the first one even though the total is the same as a single large message, and a stream of ten three megabyte messages sails through a four megabyte cap because each one is under the line. It is a per message ceiling, not a per call budget. When you are debugging one of these, the [decode tab at proto.datajutsu.com](https://proto.datajutsu.com/?ref=datajutsu.com) shows you the exact frame and the length prefix the cap is reading, so you can see for yourself that it is counting the wire bytes and not the logical field. The frame header is built in the [request body post](https://datajutsu.com/build-grpc-request-body/?ref=datajutsu.com), and that code eight you are getting is the same status that [rides in the headers](https://datajutsu.com/grpc-failed-call-returns-200/?ref=datajutsu.com), not the body, when a call fails.