# rpc error: code = ResourceExhausted desc = grpc: received message larger than max (5242881 vs. 4194304)

- **ID:** `go/grpc-message-size-exceeded`
- **Domain:** go
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The protobuf message exceeds gRPC's default 4 MiB receive limit. Common with large file uploads, batch arrays, or embedded blobs.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.40+ | active | — | — |
| 1.60+ | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Raise the limit on both client and server:
// client
conn, _ := grpc.NewClient(addr,
  grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(16*1024*1024)))
// server
srv := grpc.NewServer(grpc.MaxRecvMsgSize(16*1024*1024))
   ```
2. **** (95% success)
   ```
   Switch large payloads to streaming RPCs:
stream, _ := client.Upload(ctx)
for _, chunk := range chunks { stream.Send(chunk) }
stream.CloseAndRecv()
   ```

## Dead Ends

- **** — gRPC's limit is checked on the uncompressed logical message size in many configs; compression may not help and adds CPU cost. (70% fail)
- **** — Deterministic size violation; retries return the same error. (95% fail)
