nestjs/nest · error · Error
Method is not supported in gRPC mode. Use ClientGrpc instead
Error message
Method is not supported in gRPC mode. Use ClientGrpc instead (learn more in the documentation).
What it means
`ClientGrpcProxy.send(pattern, data)` throws because the request/response pattern-messaging API does not apply to gRPC. gRPC uses typed service clients obtained via `getService(name)`. The message directs you to use the `ClientGrpc` interface instead of `ClientProxy.send`.
Source
Thrown at packages/microservices/client/client-grpc.ts:369
public close() {
this.clients.forEach(client => {
if (client && isFunction(client.close)) {
client.close();
}
});
this.clients.clear();
this.grpcClients = [];
}
public async connect(): Promise<any> {
throw new Error('The "connect()" method is not supported in gRPC mode.');
}
public send<TResult = any, TInput = any>(
pattern: any,
data: TInput,
): Observable<TResult> {
throw new Error(
'Method is not supported in gRPC mode. Use ClientGrpc instead (learn more in the documentation).',
);
}
protected getClient(name: string): any {
return this.grpcClients.find(client =>
Object.hasOwnProperty.call(client, name),
);
}
protected publish(packet: any, callback: (packet: any) => any): any {
throw new Error(
'Method is not supported in gRPC mode. Use ClientGrpc instead (learn more in the documentation).',
);
}
protected async dispatchEvent(packet: any): Promise<any> {
throw new Error(View on GitHub (pinned to 6ec0e2783d)
Solutions
- Replace `send(pattern, data)` with `getService<T>('Svc').method(data)`.
- Define a TypeScript interface mirroring the proto service for type-safe calls.
- Audit all `send`/`emit` usages when migrating to gRPC.
Example fix
// before
client.send('sum', { data: [1, 2] }).subscribe(r => console.log(r));
// after
const math = client.getService<MathClient>('Math');
math.sum({ data: [1, 2] }).subscribe(r => console.log(r)); Defensive patterns
Strategy: type-guard
Validate before calling
import { ClientGrpc } from '@nestjs/microservices';
function useGrpcService<T>(c: ClientGrpc, name: string): T {
return c.getService<T>(name);
}
const math = useGrpcService<MathClient>(client, 'Math'); Type guard
import { ClientGrpc } from '@nestjs/microservices';
function isGrpcClient(c: unknown): c is ClientGrpc {
return typeof c === 'object' && c !== null && typeof (c as any).getService === 'function';
} Prevention
- Replace any `client.send(...)` call with `getService<T>().method(...)` when migrating to gRPC.
- Define TypeScript interfaces mirroring the proto service.
- Lint against `.send(`/`.emit(` on `ClientGrpc` instances.
When it happens
Trigger: Calling `clientGrpc.send('pattern', payload)` instead of `clientGrpc.getService('ServiceName').method(payload)`.
Common situations: Treating a gRPC client like `ClientTCP`/`ClientRedis`/`ClientNats`; copy-paste messaging code from another transport; switching transport without rewriting the call site.
Related errors
- The "connect()" method is not supported in gRPC mode.
- Method is not supported in gRPC mode.
- 3
- No consumer initialized. Please, call the "connect" method f
- No producer initialized. Please, call the "connect" method f
AI-assisted analysis of nestjs/nest@6ec0e2783d (2026-08-03).
Data as JSON: /data/errors/230ade5cb83c50c5.json.
Report an issue: GitHub.