alibaba/nacos · critical · NacosException

500

500

Error message

Server return invalid response

What it means

Thrown when the gRPC server returns a successful response (resultCode == SUCCESS) but the response object's class is not assignable to the expected responseClass (NacosException.SERVER_ERROR = 500). This indicates a protocol or version mismatch: the server sent an unexpected response type for the request.

Source

Thrown at client/src/main/java/com/alibaba/nacos/client/naming/remote/gprc/NamingGrpcClientProxy.java:538

                throw new NacosException(400, "unknown naming request type");
            }
            
            response = requestTimeout < 0 ? rpcClient.request(request)
                : rpcClient.request(request, requestTimeout);
            if (ResponseCode.SUCCESS.getCode() != response.getResultCode()) {
                // If the 403 login operation is triggered, refresh the accessToken of the client
                if (NacosException.NO_RIGHT == response.getErrorCode()) {
                    reLogin();
                }
                throw new NacosException(response.getErrorCode(), response.getMessage());
            }
            if (responseClass.isAssignableFrom(response.getClass())) {
                return (T) response;
            }
            NAMING_LOGGER.error(
                "Server return unexpected response '{}', expected response should be '{}'",
                response.getClass().getName(), responseClass.getName());
            throw new NacosException(NacosException.SERVER_ERROR, "Server return invalid response");
        } catch (NacosException e) {
            recordRequestFailedMetrics(request, e, response);
            throw e;
        } catch (Exception e) {
            recordRequestFailedMetrics(request, e, response);
            throw new NacosException(NacosException.SERVER_ERROR, "Request nacos server failed: ",
                e);
        }
    }
    
    /**
     * Records registration metrics for a service instance.
     *
     * @param request   The registration request object.
     * @param exception The Exception encountered during the registration process, or null if registration was
     *                  successful.
     * @param response  The response object containing registration result information, or null if registration failed.
     */

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Align the Nacos client and server versions to the same release line.
  2. Check the NAMING_LOGGER output for the exact expected vs. actual response class names to diagnose the mismatch.
  3. If behind a proxy or load balancer, verify it is not rewriting gRPC responses.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    namingService.registerInstance(serviceName, groupName, instance);
} catch (NacosException e) {
    if (e.getErrCode() == NacosException.SERVER_ERROR
        && "Server return invalid response".equals(e.getErrMsg())) {
        LOGGER.error("Client/server version mismatch — response type unexpected", e);
        // upgrade or downgrade to align versions
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Server returns a response type that does not match what the client expects for the given request — e.g., a newer server sends an extended response object that an older client does not recognize, or a routing/proxy returns a generic response.

Common situations: Client and server version mismatch (e.g., client v2.x talking to server v3.x with changed response types); a network middlebox or gRPC interceptor altering responses; a corrupt or misrouted response.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/56738a6d79795943. Report an issue: GitHub.